Home | Libraries | People | FAQ | More |
Start a new stackful coroutine that executes on a given execution context.
template< typename ExecutionContext, typename F, typename CompletionToken = default_completion_token_t< typename ExecutionContext::executor_type>> auto spawn( ExecutionContext & ctx, F && function, CompletionToken && token = default_completion_token_t< typename ExecutionContext::executor_type >(), constraint_t< is_convertible< ExecutionContext &, execution_context & >::value > = 0);
This function is used to launch a new stackful coroutine.
Identifies the execution context that will run the stackful coroutine.
The coroutine function. The function must be callable the signature:
void function(basic_yield_context<Executor> yield);
The completion
token that will handle the notification that the coroutine
has completed. If the return type R
of function
is void
, the function signature of the
completion handler must be:
void handler(std::exception_ptr);
Otherwise, the function signature of the completion handler must be:
void handler(std::exception_ptr, R);
void(std::exception_ptr, R)
where R
is the return type
of the function object.
The new thread of execution is created with a cancellation state that supports
cancellation_type::terminal
values only. To change the cancellation
state, call the basic_yield_context
member function
reset_cancellation_state
.