feisty meow concerns codebase  2.140
timely::timer_driver Class Reference

Provides platform-independent timer support. More...

#include <timer_driver.h>

Inheritance diagram for timely::timer_driver:
Collaboration diagram for timely::timer_driver:

Public Member Functions

 timer_driver ()
 
virtual ~timer_driver ()
 
 DEFINE_CLASS_NAME ("timer_driver")
 
bool set_timer (int duration, timeable *to_invoke)
 sets a timer to call "to_invoke" every "duration" milliseconds. More...
 
bool zap_timer (timeable *to_drop)
 removes the timer that was established for "to_drop". More...
 
void handle_system_timer ()
 invoked by the OS timer support and must be called by main thread. More...
 

Static Public Member Functions

static timer_driverglobal_timer_driver ()
 the first time this is invoked, it creates a program-wide timer driver. More...
 

Detailed Description

Provides platform-independent timer support.

Multiple objects can be hooked to the timer to be called when their interval elapses. The driver allows new timeables to be added as needed.

NOTE: Only one of the timer_driver objects is allowed per program.

Definition at line 50 of file timer_driver.h.

Constructor & Destructor Documentation

◆ timer_driver()

timely::timer_driver::timer_driver ( )

◆ ~timer_driver()

timely::timer_driver::~timer_driver ( )
virtual

Member Function Documentation

◆ DEFINE_CLASS_NAME()

timely::timer_driver::DEFINE_CLASS_NAME ( "timer_driver"  )

◆ global_timer_driver()

static timer_driver& timely::timer_driver::global_timer_driver ( )
static

the first time this is invoked, it creates a program-wide timer driver.

◆ handle_system_timer()

void timely::timer_driver::handle_system_timer ( )

invoked by the OS timer support and must be called by main thread.

Definition at line 275 of file timer_driver.cpp.

References FUNCDEF, timely::INITIAL_TIMER_GRANULARITY, basis::array< contents >::length(), LOG, timely::MAX_TIMER_PREDICTION, timely::now(), and basis::astring::t().

◆ set_timer()

bool timely::timer_driver::set_timer ( int  duration,
timeable to_invoke 
)

sets a timer to call "to_invoke" every "duration" milliseconds.

if the object "to_invoke" already exists, then its duration is changed.

Definition at line 249 of file timer_driver.cpp.

References FUNCDEF, LOG, and basis::negative().

◆ zap_timer()

bool timely::timer_driver::zap_timer ( timeable to_drop)

removes the timer that was established for "to_drop".

do not zap a timer from its own callback! that could cause synchronization problems.

Definition at line 221 of file timer_driver.cpp.

References FUNCDEF, LOG, and basis::negative().


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