boost::capy::run_async_wrapper

Wrapper returned by run_async that accepts a task for execution.

Synopsis

template<
    Executor Ex,
    class Handlers,
    class Alloc>
class run_async_wrapper;

Description

This wrapper holds the run_async_trampoline coroutine, executor, stop token, and handlers. The run_async_trampoline is allocated when the wrapper is constructed (before the task due to C++17 postfix evaluation order).

The rvalue ref‐qualifier on operator() ensures the wrapper can only be used as a temporary, preventing misuse that would violate LIFO ordering.

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.

Example

// Correct usage - wrapper is temporary
run_async(ex)(my_task());

// Compile error - cannot call operator() on lvalue
auto w = run_async(ex);
w(my_task());  // Error: operator() requires rvalue

Member Functions

Name

Description

run_async_wrapper [constructor] [deleted]

Construct wrapper with executor, stop token, handlers, and allocator.

~run_async_wrapper [destructor]

Destructor

operator= [deleted]

Assignment operators

operator()

Launch the task for execution.

Template Parameters

Name Description

Ex

The executor type satisfying the Executor concept.

Handlers

The handler type (default_handler or handler_pair).

Alloc

The allocator type (value type or memory_resource*).

See Also

run_async

Created with MrDocs