|
Clio
develop
The XRP Ledger API server.
|
A highly configurable execution context. More...
#include <BasicExecutionContext.hpp>


Public Types | |
| using | ContextHolderType = ContextType |
| The underlying context type. | |
| using | ExecutorType = ContextHolderType::Executor |
| Executor of the underlying context. | |
| template<typename T> | |
| using | ValueType = std::expected<T, ExecutionError> |
| The result type of operations: the value or an ExecutionError. | |
| using | StopSource = StopSourceType |
| The stop source type used by stoppable operations. | |
| using | StopToken = StopSourceType::Token |
| Stop token passed to stoppable user functions. | |
| template<typename T> | |
| using | StoppableOperation = StoppableOperation<ValueType<T>, StopSourceType> |
| The operation type returned for stoppable work on this context. | |
| template<typename T> | |
| using | Operation = Operation<ValueType<T>> |
| The operation type returned for non-stoppable work on this context. | |
| using | Strand |
| The strand type created by this context to serialize execution. | |
| using | Timer = ContextHolderType::Timer |
| The timer type of the underlying context. | |
| template<typename T> | |
| using | ScheduledOperation = ScheduledOperation<BasicExecutionContext, StoppableOperation<T>> |
| The operation type returned for work scheduled after a delay. | |
| using | RepeatedOperation = RepeatingOperation<BasicExecutionContext> |
| The operation type returned for work executed repeatedly at an interval. | |
Public Member Functions | |
| BasicExecutionContext (std::size_t numThreads=1) noexcept | |
| Create a new execution context with the given number of threads. | |
| ~BasicExecutionContext () override | |
| Stops the underlying thread pool. | |
| BasicExecutionContext (BasicExecutionContext &&)=default | |
| BasicExecutionContext (BasicExecutionContext const &)=delete | |
| auto | scheduleAfter (SomeStdDuration auto delay, SomeHandlerWith< StopToken > auto &&fn, std::optional< std::chrono::milliseconds > timeout=std::nullopt) noexcept(kIsNoexcept) |
| Schedule an operation on the execution context. | |
| auto | scheduleAfter (SomeStdDuration auto delay, SomeHandlerWith< StopToken, bool > auto &&fn, std::optional< std::chrono::milliseconds > timeout=std::nullopt) noexcept(kIsNoexcept) |
| Schedule an operation on the execution context. | |
| auto | executeRepeatedly (SomeStdDuration auto interval, SomeHandlerWithoutStopToken auto &&fn) noexcept(kIsNoexcept) |
| Schedule a repeating operation on the execution context. | |
| auto | execute (SomeHandlerWith< StopToken > auto &&fn, std::optional< std::chrono::milliseconds > timeout=std::nullopt) noexcept(kIsNoexcept) |
| Schedule an operation on the execution context. | |
| auto | execute (SomeHandlerWith< StopToken > auto &&fn, SomeStdDuration auto timeout) noexcept(kIsNoexcept) |
| Schedule an operation on the execution context. | |
| auto | execute (SomeHandlerWithoutStopToken auto &&fn) noexcept(kIsNoexcept) |
| Schedule an operation on the execution context. | |
| void | submit (SomeHandlerWithoutStopToken auto &&fn) noexcept(kIsNoexcept) |
| Schedule an operation on the execution context without expectations of a result. | |
| Strand | makeStrand () |
| Create a strand for this execution context. | |
| void | stop () const noexcept |
| Stop the execution context as soon as possible. | |
| void | join () const noexcept |
| Block until all operations are completed. | |
| ContextType::Executor & | getExecutor () |
| Get the underlying executor. | |
Static Public Attributes | |
| static constexpr bool | kIsNoexcept |
| Whether operations on this execution context are noexcept. | |
A highly configurable execution context.
This execution context is used as the base for all specialized execution contexts. Return values are handled by capturing them and returning them packaged as std::expected. Exceptions may or may not be caught and handled depending on the error strategy. The default behavior is to catch and package them as the error channel of std::expected.
| ContextType | The underlying context providing the executor, timer and strand types |
| StopSourceType | The stop source type used to request stopping of stoppable operations |
| DispatcherType | The strategy used to dispatch work onto the executor (post, spawn, sync) |
| TimerContextProvider | Provides the context used for scheduled and repeating operations |
| ErrorHandlerType | The strategy for catching and packaging exceptions from user functions |
| using util::async::BasicExecutionContext< ContextType, StopSourceType, DispatcherType, TimerContextProvider, ErrorHandlerType >::Operation = Operation<ValueType<T>> |
The operation type returned for non-stoppable work on this context.
| T | The type of the value produced by the operation |
| using util::async::BasicExecutionContext< ContextType, StopSourceType, DispatcherType, TimerContextProvider, ErrorHandlerType >::RepeatedOperation = RepeatingOperation<BasicExecutionContext> |
The operation type returned for work executed repeatedly at an interval.
| using util::async::BasicExecutionContext< ContextType, StopSourceType, DispatcherType, TimerContextProvider, ErrorHandlerType >::ScheduledOperation = ScheduledOperation<BasicExecutionContext, StoppableOperation<T>> |
The operation type returned for work scheduled after a delay.
| T | The type of the value produced by the operation |
| using util::async::BasicExecutionContext< ContextType, StopSourceType, DispatcherType, TimerContextProvider, ErrorHandlerType >::StoppableOperation = StoppableOperation<ValueType<T>, StopSourceType> |
The operation type returned for stoppable work on this context.
| T | The type of the value produced by the operation |
| using util::async::BasicExecutionContext< ContextType, StopSourceType, DispatcherType, TimerContextProvider, ErrorHandlerType >::Strand |
The strand type created by this context to serialize execution.
| using util::async::BasicExecutionContext< ContextType, StopSourceType, DispatcherType, TimerContextProvider, ErrorHandlerType >::ValueType = std::expected<T, ExecutionError> |
The result type of operations: the value or an ExecutionError.
| T | The type of the value produced by the operation |
|
inlineexplicitnoexcept |
Create a new execution context with the given number of threads.
| numThreads | The number of threads to use for the underlying thread pool |
|
inlinenodiscardnoexcept |
Schedule an operation on the execution context.
| fn | The block of code to execute with stop token as first arg |
| timeout | The timeout duration after which the operation will be cancelled |
|
inlinenodiscardnoexcept |
Schedule an operation on the execution context.
| fn | The block of code to execute with stop token as first arg |
| timeout | The optional timeout duration after which the operation will be cancelled |
|
inlinenodiscardnoexcept |
Schedule an operation on the execution context.
| fn | The block of code to execute. Signature is Type() where Type is the return type. |
|
inlinenodiscardnoexcept |
Schedule a repeating operation on the execution context.
| interval | The interval at which the operation should be repeated |
| fn | The block of code to execute; no args allowed and return type must be void |
|
inline |
Get the underlying executor.
Provides access to the wrapped executor for cases where the execution context needs to interact with components that require explicit executor access (like Channel).
|
inlinenodiscard |
Create a strand for this execution context.
|
inlinenodiscardnoexcept |
Schedule an operation on the execution context.
| delay | The delay after which the operation should be executed |
| fn | The block of code to execute with stop token as the only arg |
| timeout | The optional timeout duration after which the operation will be cancelled |
|
inlinenodiscardnoexcept |
Schedule an operation on the execution context.
| delay | The delay after which the operation should be executed |
| fn | The block of code to execute with stop token as the first arg and cancellation flag as the second arg |
| timeout | The optional timeout duration after which the operation will be cancelled |
|
inlinenoexcept |
Schedule an operation on the execution context without expectations of a result.
| fn | The block of code to execute |
|
staticconstexpr |
Whether operations on this execution context are noexcept.