std::execution::sync_wait(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

okay so bestie, welcome to std::execution::sync_wait(3) from the C++ Standard Libary manual πŸ’–βœ¨ this page is about a C++26 little guy that blocks and waits, and we’re gonna read it together, no cap.

πŸ’– NAME πŸ’–

std::execution::sync_wait β€” std::execution::sync_wait πŸ‘‘ (yes bestie, that’s the whole name section; it’s giving main-character repetition ✨)

🌸 Synopsis 🌸

Defined in header <execution> πŸŽ€, and the signature is literally this:

Defined in header <execution>
auto sync_wait( execution::sender auto sender )

    requires (/*always-sends-some-values*/(sender))
(since C++26)

            -> std::optional<std::tuple</*value-sent-by*/(sender)>>;

So yeah: requires (/*always-sends-some-values*/(sender)), since C++26, and the arrow points to std::optional<std::tuple</*value-sent-by*/(sender)>> πŸ’… periodt.

πŸ¦‹ Parameters πŸ¦‹

  • sender β€” the sender upon which the completion of sync_wait is blocked 🫢 that’s the whole vibe: sync_wait is blocked on this sender’s completion, fr fr.

πŸŽ€ Return value πŸŽ€

It returns an std::optional tuple of values that were sent by the provided sender on its completion of work ✨ optional tuple energy, bestie β€” that’s the whole return value, no cap.

πŸ”₯ Notes πŸ”₯

The sender returned by sync_wait is similarly to ensure_started, except that it blocks the current std::thread or thread of main until the work is completed 😭 yes, that’s the note; the blocking is the whole point, and ensure_started is the comparison, iykyk.

🌈 See also 🌈

  • function template β€” Eagerly starts a sender, returning a sender that will deliver the results to a receiver to which it is connected and started, if any. When the result sender is not connected to a receiver, or if the ensure_started resulting operation state is not started, the results are ignored. If such a sender is destroyed before the underlying operation completes, the operation continues running detached. πŸ’œ

this is the see-also entry, and it’s a function template, periodt πŸ‘‘


that’s the whole page, bestie 🫢 source: http://cppreference.com; version/date: 2024.06.10; page: std::execution::sync_wait(3). periodt πŸ’…

πŸ“¦ where this page comes from