boost::capy::executor_ref
Forwards dispatch/`post`/`context` calls through a non‐owning, type‐erased executor pointer.
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. Executors of different types are therefore 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 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
// my_continuation must stay at a stable address until the executor
// dequeues it, so it is owned by the caller, not by store_executor().
void store_executor(capy::executor_ref ex, capy::continuation& my_continuation)
{
if(ex)
ex.post(my_continuation);
}
void use_thread_pool(capy::thread_pool& ctx, capy::continuation& my_continuation)
{
store_executor(ctx.get_executor(), my_continuation);
}
Member Functions
Name |
Description |
|
Constructors |
Copy assignment operator. |
|
Returns a reference to the associated execution context. |
|
Dispatches a continuation through the wrapped executor. |
|
Informs the executor that work has completed. |
|
Informs the executor that work is beginning. |
|
Posts a continuation 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
Created with MrDocs