Difference between revisions of "cpp/thread/this thread/sync wait"
From cppreference.com
(move to cpp/experimental) |
m (Reverted edits by Cooky (talk) to last revision by Space Mission) |
||
Line 1: | Line 1: | ||
+ | {{cpp/execution/title|sync_wait}} | ||
+ | {{cpp/experimental/execution/navbar}} | ||
+ | <!--{{cpp/execution/navbar}}--> | ||
+ | {{ddcl|header=execution|since=c++26| | ||
+ | auto sync_wait( execution::sender auto sender ) | ||
+ | requires (/*always-sends-some-values*/(sender)) | ||
+ | -> std::optional<std::tuple</*value-sent-by*/(sender)>>; | ||
+ | }} | ||
+ | ===Parameters=== | ||
+ | {{par begin}} | ||
+ | {{par|sender|sender upon which the completion of {{lc|sync_wait}} is blocked}} | ||
+ | {{par end}} | ||
+ | |||
+ | ===Return value=== | ||
+ | Returns an optional tuple of values that were sent by the provided sender on its completion of work. | ||
+ | |||
+ | ===Notes=== | ||
+ | The sender returned by {{tt|sync_wait}} similarly to {{tt|ensure_started}}, except that it blocks the current {{lc|std::thread}} or thread of main until the work is completed. | ||
+ | |||
+ | ===See also=== | ||
+ | {{dsc begin}} | ||
+ | {{dsc inc|cpp/experimental/dsc ensure_started}} | ||
+ | {{dsc end}} | ||
+ | |||
+ | {{langlinks|zh}} |
Revision as of 18:29, 3 October 2024
Defined in header <execution>
|
||
auto sync_wait( execution::sender auto sender ) requires (/*always-sends-some-values*/(sender)) |
(since C++26) | |
Contents |
Parameters
sender | - | sender upon which the completion of sync_wait is blocked |
Return value
Returns an optional tuple of values that were sent by the provided sender on its completion of work.
Notes
The sender returned by sync_wait
similarly to ensure_started
, except that it blocks the current std::thread or thread of main until the work is completed.
See also
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 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. (function template) |