CatapultServer  v0.5.0.1 (Elephant)
catapult::thread::StrandedTimedCallback< TCallback, TCallbackArgs > Class Template Reference
Inheritance diagram for catapult::thread::StrandedTimedCallback< TCallback, TCallbackArgs >:
Collaboration diagram for catapult::thread::StrandedTimedCallback< TCallback, TCallbackArgs >:

Classes

class  BasicTimedCallback
 Wraps a callback with a timer using an implicit strand. More...
 

Public Member Functions

 StrandedTimedCallback (boost::asio::io_context &ioContext, const TCallback &callback, TCallbackArgs &&... timeoutArgs)
 
void setTimeout (const utils::TimeSpan &timeout)
 Sets the timeout to timeout (starting from now). More...
 
void setTimeoutHandler (const TimeoutHandlerType &handler)
 Sets the timeout handler to timeoutHandler. More...
 
template<typename... TArgs>
void callback (TArgs &&... args)
 Invokes the wrapped callback with args. More...
 
template<typename THandler >
auto wrap (THandler handler)
 

Private Types

using TimeoutHandlerType = action
 

Private Member Functions

template<typename THandler >
void post (THandler handler)
 

Private Attributes

BasicTimedCallback< StrandedTimedCallbackm_impl
 
boost::asio::io_context::strand m_strand
 
StrandOwnerLifetimeExtender< StrandedTimedCallbackm_strandWrapper
 

Detailed Description

template<typename TCallback, typename... TCallbackArgs>
class catapult::thread::StrandedTimedCallback< TCallback, TCallbackArgs >

Wraps a callback with a timer using an explicit strand and ensures deterministic shutdown by using enable_shared_from_this.

Member Typedef Documentation

◆ TimeoutHandlerType

template<typename TCallback , typename... TCallbackArgs>
using catapult::thread::StrandedTimedCallback< TCallback, TCallbackArgs >::TimeoutHandlerType = action
private

Constructor & Destructor Documentation

◆ StrandedTimedCallback()

template<typename TCallback , typename... TCallbackArgs>
catapult::thread::StrandedTimedCallback< TCallback, TCallbackArgs >::StrandedTimedCallback ( boost::asio::io_context &  ioContext,
const TCallback &  callback,
TCallbackArgs &&...  timeoutArgs 
)
inline

Creates a timed callback by wrapping callback with a timed callback using ioContext. On a timeout, the callback is invoked with timeoutArgs.

Member Function Documentation

◆ callback()

template<typename TCallback , typename... TCallbackArgs>
template<typename... TArgs>
void catapult::thread::StrandedTimedCallback< TCallback, TCallbackArgs >::callback ( TArgs &&...  args)
inline

Invokes the wrapped callback with args.

Here is the call graph for this function:

◆ post()

template<typename TCallback , typename... TCallbackArgs>
template<typename THandler >
void catapult::thread::StrandedTimedCallback< TCallback, TCallbackArgs >::post ( THandler  handler)
inlineprivate
Here is the caller graph for this function:

◆ setTimeout()

template<typename TCallback , typename... TCallbackArgs>
void catapult::thread::StrandedTimedCallback< TCallback, TCallbackArgs >::setTimeout ( const utils::TimeSpan timeout)
inline

Sets the timeout to timeout (starting from now).

Here is the call graph for this function:

◆ setTimeoutHandler()

template<typename TCallback , typename... TCallbackArgs>
void catapult::thread::StrandedTimedCallback< TCallback, TCallbackArgs >::setTimeoutHandler ( const TimeoutHandlerType handler)
inline

Sets the timeout handler to timeoutHandler.

Here is the call graph for this function:

◆ wrap()

template<typename TCallback , typename... TCallbackArgs>
template<typename THandler >
auto catapult::thread::StrandedTimedCallback< TCallback, TCallbackArgs >::wrap ( THandler  handler)
inline

Member Data Documentation

◆ m_impl

template<typename TCallback , typename... TCallbackArgs>
BasicTimedCallback<StrandedTimedCallback> catapult::thread::StrandedTimedCallback< TCallback, TCallbackArgs >::m_impl
private

◆ m_strand

template<typename TCallback , typename... TCallbackArgs>
boost::asio::io_context::strand catapult::thread::StrandedTimedCallback< TCallback, TCallbackArgs >::m_strand
private

◆ m_strandWrapper

template<typename TCallback , typename... TCallbackArgs>
StrandOwnerLifetimeExtender<StrandedTimedCallback> catapult::thread::StrandedTimedCallback< TCallback, TCallbackArgs >::m_strandWrapper
private

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