Boost
C++ Libraries
...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Submits a function to be run on a specified execution context, and after completion submits the completion handler.
template< typename Function, typename ExecutionContext, typename NullaryToken = default_completion_token_t<typename ExecutionContext::executor_type>> auto dispatch( Function && function, ExecutionContext & ctx, NullaryToken && token = default_completion_token_t< typename ExecutionContext::executor_type >(), constraint_t< is_void< result_of_t< decay_t< Function >()> >::value > = 0, constraint_t< is_convertible< ExecutionContext &, execution_context & >::value > = 0);
A nullary function to be executed on the target executor.
An execution context, from which the target executor is obtained.
The completion token that will be used to produce a completion handler. The function signature of the completion handler must be:
void handler();
dispatch(forward<Function>(function),
ctx.get_executor(),
forward<NullaryToken>(token)).
If the function object throws an exception, that exception is allowed to
propagate to the target executor. The behaviour in this case is dependent
on the executor. For example, io_context will allow the exception
to propagate to the caller that runs the io_context,
whereas thread_pool will call std::terminate.
void()