Working with Asynchrony Generically: A Tour of C++ Executorsdone_as_optional(sender) → sender … commutes the done signal into a nullopt. done_as_error(sender, error) → sender … commutes the done signal into an error.19 SENDER/RECEIVER CONTROL FLOW20 BASIC The cancellation “exception” is “caught” by applying a sender adaptor that translates the done signal into a value or an error before awaiting the sender; e.g., with: • std::execution::done_as_optional() inline std::atomicpending_{nullptr}; static BOOL WINAPI consoleHandler(DWORD signal) { if (signal == CTRL_C_EVENT) { if (auto* pending = pending_.exchange(nullptr)) pending->complete(); 0 码力 | 121 页 | 7.73 MB | 6 月前3
基于 Rust Arrow Flight 的物联网和时序数据传输及转换工具 霍琳贺tokio_util::sync::CancellationToken 可用于向一个或多个任务发出取 消信号, Task 内使用 tokio::select! 宏执行相关取消操作。 • tokio::signal::ctrl_c 接收 Ctrl-C 信号,可用于最终程序退出时的取 消操作。 • 谨慎处理任务中 channel 的结束信号。 • cancel vs. abort : Cancel 处理按预期退出,0 码力 | 29 页 | 2.26 MB | 1 年前3
共 2 条
- 1













