Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

post (6 of 7 overloads)

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 post(
    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);
Parameters

function

A nullary function to be executed on the target executor.

ctx

An execution context, from which the target executor is obtained.

token

The completion token that will be used to produce a completion handler. The function signature of the completion handler must be:

void handler();
Return Value

post(forward<Function>(function), ctx.get_executor(), forward<NullaryToken>(token)).

Remarks

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.

Completion Signature
void()

PrevUpHomeNext