boost::capy::run_async
Bind an executor, a stop token, and separate result and error handlers to produce a launcher. Invoke the launcher with a task to start it.
Synopsis
Declared in <boost/capy/ex/run_async.hpp>
template<
Executor Ex,
class H1,
class H2>
requires (detail::RunAsyncHandler<H1> && detail::RunAsyncHandler<H2>)
[[nodiscard]]
auto
run_async(
Ex ex,
std::stop_token st,
H1 h1,
H2 h2);
Description
The stop token is propagated to the task for cooperative cancellation. The handler h1 is called on success, h2 on failure.
Construct the task as the direct argument of the two‐call expression run_async(ex)(task).
Thread Safety
The wrapper itself should only be used from one thread. The handlers may be invoked from any thread where the executor schedules work.
Return Value
A wrapper that accepts a task<T> for immediate execution.
|
The return value should not be discarded. |
Parameters
Name |
Description |
ex |
The executor to execute the task on. |
st |
The stop token for cooperative cancellation. |
h1 |
The handler to invoke with the result on success. |
h2 |
The handler to invoke with the exception on failure. |