boost::capy::executor_ref
A type‐erased reference wrapper for executor objects.
Synopsis
Declared in <boost/capy/ex/executor_ref.hpp>
class executor_ref;
Description
This class provides type erasure for any executor type, enabling runtime polymorphism without virtual functions or allocation. It stores a pointer to the original executor and a pointer to a static vtable, allowing executors of different types to be stored uniformly while satisfying the full Executor concept.
Reference Semantics
This class has reference semantics: it does not allocate or own the wrapped executor. Copy operations simply copy the internal pointers. The caller must ensure the referenced executor outlives all executor_ref instances that wrap it.
Thread Safety
The executor_ref itself is not thread‐safe for concurrent modification, but its executor operations are safe to call concurrently if the underlying executor supports it.
Executor Concept
This class satisfies the Executor concept, making it usable anywhere a concrete executor is expected.
Example
void store_executor(executor_ref ex)
{
if(ex)
ex.post(my_coroutine);
}
io_context ctx;
store_executor(ctx.get_executor());
Member Functions
Name |
Description |
|
Constructors |
Copy assignment operator. |
|
Returns a reference to the associated execution context. |
|
Dispatches a coroutine handle through the wrapped executor. |
|
Informs the executor that work has completed. |
|
Informs the executor that work is beginning. |
|
Posts a coroutine handle to the wrapped executor. |
|
Return a pointer to the wrapped executor if it matches the requested type. |
|
Returns true if this instance holds a valid executor. |
|
Compares two executor references for equality. |
See Also
any_executor, Executor
Created with MrDocs