boost::capy::any_executor
A type‐erased wrapper for executor objects.
Synopsis
Declared in <boost/capy/ex/any_executor.hpp>
class any_executor;
Description
This class provides type erasure for any executor type, enabling runtime polymorphism with automatic memory management via shared ownership. It stores a shared pointer to a polymorphic wrapper, allowing executors of different types to be stored uniformly while satisfying the full Executor concept.
Value Semantics
This class has value semantics with shared ownership. Copy and move operations are cheap, simply copying the internal shared pointer. Multiple any_executor instances may share the same underlying executor. Move operations do not invalidate the source; there is no moved‐from state.
Default State
A default‐constructed any_executor holds no executor. Calling executor operations on a default‐constructed instance results in undefined behavior. Use operator bool() to check validity.
Thread Safety
The any_executor itself is thread‐safe for concurrent reads. Concurrent modification requires external synchronization. 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
any_executor exec = ctx.get_executor();
if(exec)
{
auto& context = exec.context();
exec.post(my_coroutine);
}
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. |
|
Returns the type_info of the wrapped executor. |
|
Returns true if this instance holds a valid executor. |
|
Compares two executor wrappers for equality. |
See Also
executor_ref, Executor
Created with MrDocs