Namespaces
Variants

std::execution:: sync_wait

From cppreference.net
定义于头文件 <execution>
auto sync_wait ( execution :: sender auto sender )

requires ( /*always-sends-some-values*/ ( sender ) )

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

目录

参数

sender - 等待 sync_wait 完成所阻塞的发送器

返回值

返回一个可选元组,其中包含由指定发送方在其工作完成时发送的值。

注释

ensure_started 类似, sync_wait 返回的发送器会阻塞当前 std::thread 或主线程,直到工作完成。

参见

急切地启动一个 sender,返回一个 sender,该 sender 会将结果传递给已连接并启动的 receiver(如果存在)。当结果 sender 未连接到 receiver,或生成的操作状态未启动时,结果将被忽略。若此类 sender 在底层操作完成前被销毁,操作将继续以分离状态运行。
(函数模板)