Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
util::async::AnyExecutionContext Class Reference

A type-erased execution context. More...

#include <AnyExecutionContext.hpp>

Public Member Functions

template<NotSameAs< AnyExecutionContext > CtxType>
 AnyExecutionContext (CtxType &ctx)
 Construct a new type-erased Execution Context object.
 
template<RValueNotSameAs< AnyExecutionContext > CtxType>
 AnyExecutionContext (CtxType &&ctx)
 Construct a new type-erased Execution Context object.
 
 AnyExecutionContext (AnyExecutionContext const &)=default
 
 AnyExecutionContext (AnyExecutionContext &&)=default
 
AnyExecutionContextoperator= (AnyExecutionContext const &)=default
 
AnyExecutionContextoperator= (AnyExecutionContext &&)=default
 
auto execute (SomeHandlerWithoutStopToken auto &&fn)
 Execute a function on the execution context.
 
auto execute (SomeHandlerWith< AnyStopToken > auto &&fn)
 Execute a function on the execution context.
 
auto execute (SomeHandlerWith< AnyStopToken > auto &&fn, SomeStdDuration auto timeout)
 Execute a function with a timeout.
 
auto scheduleAfter (SomeStdDuration auto delay, SomeHandlerWith< AnyStopToken > auto &&fn)
 Schedule a function for execution.
 
auto scheduleAfter (SomeStdDuration auto delay, SomeHandlerWith< AnyStopToken, bool > auto &&fn)
 Schedule a function for execution.
 
auto executeRepeatedly (SomeStdDuration auto interval, SomeHandlerWithoutStopToken auto &&fn)
 Schedule a repeating operation on the execution context.
 
auto makeStrand ()
 Make a strand for this execution context.
 
void stop () const
 Stop the execution context.
 
void join () const
 Join the execution context.
 

Detailed Description

A type-erased execution context.

Constructor & Destructor Documentation

◆ AnyExecutionContext() [1/2]

template<NotSameAs< AnyExecutionContext > CtxType>
util::async::AnyExecutionContext::AnyExecutionContext ( CtxType & ctx)
inline

Construct a new type-erased Execution Context object.

Note
Stores the Execution Context by reference.
Template Parameters
CtxTypeThe type of the execution context to wrap
Parameters
ctxThe execution context to wrap

◆ AnyExecutionContext() [2/2]

template<RValueNotSameAs< AnyExecutionContext > CtxType>
util::async::AnyExecutionContext::AnyExecutionContext ( CtxType && ctx)
inline

Construct a new type-erased Execution Context object.

Note
Stores the Execution Context by moving it into the AnyExecutionContext.
Template Parameters
CtxTypeThe type of the execution context to wrap
Parameters
ctxThe execution context to wrap

Member Function Documentation

◆ execute() [1/3]

auto util::async::AnyExecutionContext::execute ( SomeHandlerWith< AnyStopToken > auto && fn)
inlinenodiscard

Execute a function on the execution context.

Parameters
fnThe function to execute
Returns
A stoppable operation that can be used to wait for the result
Note
The function is expected to take a stop token

◆ execute() [2/3]

auto util::async::AnyExecutionContext::execute ( SomeHandlerWith< AnyStopToken > auto && fn,
SomeStdDuration auto timeout )
inlinenodiscard

Execute a function with a timeout.

Parameters
fnThe function to execute
timeoutThe timeout after which the function should be cancelled
Returns
A stoppable operation that can be used to wait for the result
Note
The function is expected to take a stop token

◆ execute() [3/3]

auto util::async::AnyExecutionContext::execute ( SomeHandlerWithoutStopToken auto && fn)
inlinenodiscard

Execute a function on the execution context.

Parameters
fnThe function to execute
Returns
A unstoppable operation that can be used to wait for the result

◆ executeRepeatedly()

auto util::async::AnyExecutionContext::executeRepeatedly ( SomeStdDuration auto interval,
SomeHandlerWithoutStopToken auto && fn )
inlinenodiscard

Schedule a repeating operation on the execution context.

Parameters
intervalThe interval at which the operation should be repeated
fnThe block of code to execute; no args allowed and return type must be void
Returns
A repeating stoppable operation that can be used to wait for its cancellation

◆ makeStrand()

auto util::async::AnyExecutionContext::makeStrand ( )
inlinenodiscard

Make a strand for this execution context.

Returns
A strand for this execution context
Note
The strand can be used similarly to the execution context and guarantees serial execution of all submitted operations

◆ scheduleAfter() [1/2]

auto util::async::AnyExecutionContext::scheduleAfter ( SomeStdDuration auto delay,
SomeHandlerWith< AnyStopToken > auto && fn )
inlinenodiscard

Schedule a function for execution.

Parameters
delayThe delay after which the function should be executed
fnThe function to execute
Returns
A stoppable operation that can be used to wait for the result
Note
The function is expected to take a stop token

◆ scheduleAfter() [2/2]

auto util::async::AnyExecutionContext::scheduleAfter ( SomeStdDuration auto delay,
SomeHandlerWith< AnyStopToken, bool > auto && fn )
inlinenodiscard

Schedule a function for execution.

Parameters
delayThe delay after which the function should be executed
fnThe function to execute
Returns
A stoppable operation that can be used to wait for the result
Note
The function is expected to take a stop token and a boolean representing whether the scheduled operation got cancelled

The documentation for this class was generated from the following file: