asio
asio copied to clipboard
exceptions should cancel parallel coroutines
I'm using a || operator to wait for one of the 2 coroutines:
void wait_one(awaitable a1, awaitable a2) {
auto future = co_spawn(io_context, a1 || a2, use_future);
future.wait();
}
If one of the two finishes, I expect another one to be cancelled using per-operation cancellation mechanisms and throwing a system_error with operation_canceled code.
I've found that if a2 throws an unhandled exception (even system_error/operation_canceled), this is not happening.
The future.wait() just waits forever.
I'd expect that if a2 throws anything, this triggers cancellation of the combined task, and the whole future finishes.
Note: that if a2 finishes normally without an exception, it works as expected.
I'm using asio from boost 1.78. Compiling using Apple clang version 13.1.6 (clang-1316.0.21.2) from Xcode 13 on macOS 12.4.