![]() |
Home | Libraries | People | FAQ | More |
Helper function for implementing an asynchronous operation's initiating function.
template< typename CompletionToken, completion_signature... Signatures, typename Initiation, typename... Args> DEDUCED async_initiate( Initiation && initiation, type_identity_t< CompletionToken > & token, Args &&... args);
The async_initiate function wraps the async_result trait. It automatically
performs the necessary decay and forward of the completion token, and also
enables backwards compatibility with legacy completion token implementations.
A function object that will be called to launch the asynchronous operation. It receives the concrete completion handler as its first argument, followed by any additional arguments passed to async_initiate.
The completion
token provided by the user. This will be transformed into a
concrete completion handler by the async_result trait.
Additional arguments to be forwarded to the initiation function object.
The return value is determined by the async_result specialisation for
the completion token type. For callback-based tokens, returns void. For other tokens such as use_future
or use_awaitable, returns the corresponding future or awaitable type.
Asynchronous operation implementations should use this function rather than
directly using the async_result trait, or the legacy
async_completion
helper template.
For a more detailed discussion of the role of async_result and async_initiate,
see the overview documentation for completion
token.
Header: boost/asio/async_result.hpp
Convenience header: boost/asio.hpp