mxnet
Public Member Functions | Static Public Member Functions | List of all members
dmlc::TimerThread< Duration > Class Template Reference

Managed timer thread. More...

#include <thread_group.h>

Inheritance diagram for dmlc::TimerThread< Duration >:
Inheritance graph
Collaboration diagram for dmlc::TimerThread< Duration >:
Collaboration graph

Public Member Functions

 TimerThread (const std::string &name, ThreadGroup *owner)
 Constructor. More...
 
 ~TimerThread () override
 Destructor. More...
 
template<typename OnTimerFunction >
int run (OnTimerFunction on_timer_function)
 Internal timer execution function. More...
 
- Public Member Functions inherited from dmlc::ThreadGroup::Thread
 Thread (std::string threadName, ThreadGroup *owner, std::thread *thrd=nullptr)
 Constructor. More...
 
virtual ~Thread ()
 Destructor with cleanup. More...
 
const char * name () const
 Name of the thread. More...
 
bool is_current_thread () const
 Check if this class represents the currently running thread (self) More...
 
virtual void request_shutdown ()
 Signal to this thread that a thread shutdown/exit is requested. More...
 
virtual bool is_shutdown_requested () const
 Check whether shutdown has been requested (request_shutdown() was called) More...
 
bool is_auto_remove () const
 Check whether the thread is set to auto-remove itself from the ThreadGroup owner when exiting. More...
 
void make_joinable ()
 Make the thread joinable (by removing the auto_remove flag) More...
 
bool joinable () const
 Check whether the thread is joinable. More...
 
void join ()
 Thread join. More...
 
std::thread::id get_id () const
 Get this thread's id. More...
 

Static Public Member Functions

template<typename SecondaryFunction >
static bool launch_run (std::shared_ptr< TimerThread< Duration >> pThis, SecondaryFunction secondary_function)
 Launch to the 'run' function which will, in turn, call the class' 'run' function, passing it the given 'secondary_function' for it to call as needed. More...
 
template<typename Function >
static void start (std::shared_ptr< TimerThread > timer_thread, Duration duration, Function function)
 Start a given timer thread. More...
 
- Static Public Member Functions inherited from dmlc::ThreadGroup::Thread
template<typename StartFunction , typename... Args>
static bool launch (std::shared_ptr< Thread > pThis, bool autoRemove, StartFunction start_function, Args...args)
 Launch the given Thread object. More...
 

Additional Inherited Members

- Public Types inherited from dmlc::ThreadGroup::Thread
using SharedPtr = std::shared_ptr< Thread >
 Shared pointer type for readability. More...
 

Detailed Description

template<typename Duration>
class dmlc::TimerThread< Duration >

Managed timer thread.

Template Parameters
DurationDuration type (ie seconds, microseconds, etc)

Constructor & Destructor Documentation

template<typename Duration >
dmlc::TimerThread< Duration >::TimerThread ( const std::string &  name,
ThreadGroup owner 
)
inline

Constructor.

Parameters
nameName of the timer thread
ownerThreadGroup owner if the timer thread
template<typename Duration >
dmlc::TimerThread< Duration >::~TimerThread ( )
inlineoverride

Destructor.

Member Function Documentation

template<typename Duration >
template<typename SecondaryFunction >
static bool dmlc::TimerThread< Duration >::launch_run ( std::shared_ptr< TimerThread< Duration >>  pThis,
SecondaryFunction  secondary_function 
)
inlinestatic

Launch to the 'run' function which will, in turn, call the class' 'run' function, passing it the given 'secondary_function' for it to call as needed.

Template Parameters
SecondaryFunctionType of the secondary function for 'run' override to call as needed
Parameters
pThisPointer to the managed thread to launch
secondary_functionsecondary function for 'run' override to call as needed
Returns
true if thread is launched successfully and added to the ThreadGroup
template<typename Duration >
template<typename OnTimerFunction >
int dmlc::TimerThread< Duration >::run ( OnTimerFunction  on_timer_function)
inline

Internal timer execution function.

Template Parameters
OnTimerFunctionType of function to call each time the timer expires
Parameters
on_timer_functionFunction to call each time the timer expires
Returns
Exit code of the thread
template<typename Duration >
template<typename Function >
static void dmlc::TimerThread< Duration >::start ( std::shared_ptr< TimerThread< Duration > >  timer_thread,
Duration  duration,
Function  function 
)
inlinestatic

Start a given timer thread.

Template Parameters
FunctionType of the timer function
Parameters
timer_threadThread object to perform the timer events
durationDuration between the end end of the timer function and the next timer event
functionFunction to call when the timer expires
Note
Calling shutdown_requested() will cause the thread to exit the next time that the timer expires.

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