boost::capy::run_async
Asynchronously launch a lazy task with separate result and error handlers.
Synopsis
Declared in <boost/capy/ex/run_async.hpp>
template<
Executor Ex,
/* implementation-defined */ H1,
class H2>
[[nodiscard]]
auto
run_async(
Ex ex,
H1 h1,
H2 h2);
Description
The handler h1 is called with the task's result on success. The handler h2 is called with the exception_ptr on failure.
Example
run_async(ex,
[](int result) { std::cout << "Got: " << result << "\n"; },
[](std::exception_ptr ep) {
try { std::rethrow_exception(ep); }
catch (std::exception const& e) {
std::cout << "Error: " << e.what() << "\n";
}
}
)(compute_value());
Asynchronously launch a lazy task with allocator and handler.
Parameters
| Name | Description |
|---|---|
ex |
The executor to execute the task on. |
h1 |
The handler to invoke with the result on success. |
h2 |
The handler to invoke with the exception on failure. |
alloc |
The allocator for frame allocation (copied and stored). |