boost::capy::run_async

Asynchronously launch a lazy task with stop token support.

Synopsis

template<Executor Ex>
[[nodiscard]]
auto
run_async(
    Ex ex,
    std::stop_token st);

Description

The stop token is propagated to the task, enabling cooperative cancellation. With no handlers, the result is discarded and exceptions are rethrown.

Thread Safety

The wrapper may be called from any thread where the executor schedules work.

Example

std::stop_source source;
run_async(ex, source.get_token())(cancellable_task());
// Later: source.request_stop();

Return Value

A wrapper that accepts a task<T> for immediate execution.

Parameters

Name Description

ex

The executor to execute the task on.

st

The stop token for cooperative cancellation.

See Also

task

executor

Created with MrDocs