Skip to content

Commit 940502e

Browse files
committed
asioexec::completion_token & ::use_sender
Adds two completion tokens for interop with Boost.Asio (standalone Asio not currently supported but would be simple to support in the future). asioexec::completion_token performs the most basic transformations necessary to transform an Asio initiating function into a sender factory: - The initiating function returns a sender - Initiation is deferred until the above-mentioned sender is connected and the resulting operation state is started - The completion handler provided to the initiation (see boost::asio:: async_initiate) has the following properties: - Invocation results in the arguments thereto being sent via a value completion signal (this means that errors transmitted via a leading boost::system::error_code parameter (i.e. in Asio style) are delivered in the value channel, see below) - Abandonment thereof (i.e. allowing the lifetime of the completion handler, and all objects transitively derived by moving therefrom, to end without invoking any of them) results in a stopped completion signal - Any exception thrown from any intermediate completion handler, or the final completion handler, is sent via an error completion signal with a std::exception_ptr representing that exception (this is accomplished by wrapping the associated executor) - The cancellation slot is connected to a cancellation signal which is sent when a stop request is received via the receiver's associated stop token The fact that invocations of the completion handler are passed to the value channel untouched reflects the design intent that the above- described completion token perform only "the most basic transformations necessary." This means that the full context of partial success must be made available and since the error channel is unary this must be transmitted in the value channel. For a more ergonomic experience than that described above asioexec:: use_sender is also provided. This uses asioexec::completion_token to adapt an Asio initiating function into a sender factory and wraps the returned sender with an additional layer which performs the following transformations to value completion signals with a leading boost:: system::error_code parameter: - If that argument compares equal to boost::asio::error:: operation_aborted transforms the value completion signal into a stopped completion signal, otherwise - If that argument is truthy transforms the value completion signal into an error completion signal with an appropriate std::exception_ptr (i.e. one which points to a boost::system::system_error), otherwise - Sends the remainder of the arguments (i.e. all but the boost::system:: error_code) as a value completion signal
1 parent 6d490fc commit 940502e

2 files changed

Lines changed: 567 additions & 0 deletions

File tree

0 commit comments

Comments
 (0)