Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
util::async::RepeatingOperation< CtxType > Class Template Reference

The future side of async operations that automatically repeat until aborted. More...

#include <Operation.hpp>

Inheritance diagram for util::async::RepeatingOperation< CtxType >:
Collaboration diagram for util::async::RepeatingOperation< CtxType >:

Public Member Functions

 RepeatingOperation (auto &executor, std::chrono::steady_clock::duration interval, std::invocable auto &&fn)
 Construct a new Repeating Operation object.
 
 RepeatingOperation (RepeatingOperation const &)=delete
 
RepeatingOperationoperator= (RepeatingOperation const &)=delete
 
 RepeatingOperation (RepeatingOperation &&)=default
 
RepeatingOperationoperator= (RepeatingOperation &&)=default
 
void abort () noexcept
 Aborts the operation and the repeating timer.
 
- Public Member Functions inherited from util::MoveTracker
 MoveTracker (MoveTracker &&other)
 Move constructor sets the moved-from state on other and resets the state on this
 
MoveTrackeroperator= (MoveTracker &&other)
 Move operator sets the moved-from state on other and resets the state on this
 
 MoveTracker (MoveTracker const &)=default
 
MoveTrackeroperator= (MoveTracker const &)=default
 

Additional Inherited Members

- Protected Member Functions inherited from util::MoveTracker
bool wasMoved () const noexcept
 The function to be used by clients in order to check whether the instance was moved from.
 

Detailed Description

template<typename CtxType>
class util::async::RepeatingOperation< CtxType >

The future side of async operations that automatically repeat until aborted.

Note
The current implementation requires the user provided function to return void and to take no arguments. There is also no mechanism to request the repeating task to stop from inside of the user provided block of code.
Template Parameters
CtxTypeThe type of the execution context

Constructor & Destructor Documentation

◆ RepeatingOperation()

template<typename CtxType >
util::async::RepeatingOperation< CtxType >::RepeatingOperation ( auto & executor,
std::chrono::steady_clock::duration interval,
std::invocable auto && fn )
inline

Construct a new Repeating Operation object.

Note
The first invocation of the user-provided function happens with no delay
Parameters
executorThe executor to operate on
intervalTime to wait before repeating the user-provided block of code
fnThe function to execute repeatedly

Member Function Documentation

◆ abort()

template<typename CtxType >
void util::async::RepeatingOperation< CtxType >::abort ( )
inlinenoexcept

Aborts the operation and the repeating timer.

Note
This call blocks until the underlying timer is cancelled
Warning
Calling this from inside of the repeating operation yields a deadlock

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