Thread portable class


Gate portable class


Timer class


Pool class


Terimber 2.0


About C++


Downloads Products & Services Support Clients Open Source About



Home / Open source / Terimber 2.0

timer Class Reference

timer More...

#include <timer.h>

Inheritance diagram for timer:

terimber_thread_employer

List of all members.

Public Member Functions

 timer ()
 constructor
 ~timer ()
 destructor
void activate (timer_callback *callback, size_t ident, size_t interval, size_t multiplier=1, bool reactivate=true)
 activates the timer
void deactivate ()
 deactivates stops timer

Protected Member Functions

virtual bool v_has_job (size_t ident, void *user_data)
 checks job
virtual void v_do_job (size_t ident, void *user_data)
 does job

Private Attributes

thread _thread
 thread that will fire events
mutex _mtx
 multithreaded mutex
size_t _ident
 timer ident
size_t _interval
 interval of timer events in msec
size_t _multiplier
 multiplier of timer interval
size_t _trigger
 keep the remain interval before firing timer event
bool _reactivate
 reactivation flag
bool _first
 flag of first firing
timer_callback_callback
 keep callback object pointer


Detailed Description

timer

Definition at line 55 of file timer.h.


Constructor & Destructor Documentation

BEGIN_TERIMBER_NAMESPACE timer::timer (  ) 

constructor

Definition at line 33 of file timer.cpp.

timer::~timer (  ) 

destructor

Definition at line 44 of file timer.cpp.

References deactivate().


Member Function Documentation

void timer::activate ( timer_callback callback,
size_t  ident,
size_t  interval,
size_t  multiplier = 1,
bool  reactivate = true 
)

activates the timer

Parameters:
callback  user callback
ident  timer ident, one timer callback object can handle multiple timers
interval  repeatition interval in milliseconds
multiplier  multiplier coefficient for repeatition interval
reactivate  reactivate flag (repeat firing timer events

Definition at line 50 of file timer.cpp.

References _callback, _first, _ident, _interval, _mtx, _multiplier, _reactivate, _thread, _trigger, thread::assign_job(), deactivate(), and thread::start().

Referenced by daemon::daemon_start(), and msg_communicator::v_on().

void timer::deactivate (  ) 

deactivates stops timer

Definition at line 76 of file timer.cpp.

References _mtx, _thread, thread::cancel_job(), and thread::stop().

Referenced by activate(), daemon::daemon_start(), msg_communicator::v_off(), and ~timer().

bool timer::v_has_job ( size_t  ident,
void *  user_data 
) [protected, virtual]

checks job

terimber_thread_employer

Parameters:
ident  thread ident
user_data  user defined data

Implements terimber_thread_employer.

Definition at line 87 of file timer.cpp.

References _trigger.

void timer::v_do_job ( size_t  ident,
void *  user_data 
) [protected, virtual]

does job

Parameters:
ident  thread ident
user_data  user defined data

Implements terimber_thread_employer.

Definition at line 94 of file timer.cpp.

References _callback, _first, _ident, _interval, _multiplier, _reactivate, _trigger, and timer_callback::notify().


Member Data Documentation

thread that will fire events

Definition at line 89 of file timer.h.

Referenced by activate(), and deactivate().

mutex timer::_mtx [private]

multithreaded mutex

Definition at line 90 of file timer.h.

Referenced by activate(), and deactivate().

size_t timer::_ident [private]

timer ident

Definition at line 91 of file timer.h.

Referenced by activate(), and v_do_job().

size_t timer::_interval [private]

interval of timer events in msec

Definition at line 92 of file timer.h.

Referenced by activate(), and v_do_job().

size_t timer::_multiplier [private]

multiplier of timer interval

Definition at line 93 of file timer.h.

Referenced by activate(), and v_do_job().

size_t timer::_trigger [private]

keep the remain interval before firing timer event

Definition at line 94 of file timer.h.

Referenced by activate(), v_do_job(), and v_has_job().

bool timer::_reactivate [private]

reactivation flag

Definition at line 95 of file timer.h.

Referenced by activate(), and v_do_job().

bool timer::_first [private]

flag of first firing

Definition at line 96 of file timer.h.

Referenced by activate(), and v_do_job().

keep callback object pointer

Definition at line 97 of file timer.h.

Referenced by activate(), and v_do_job().


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


© Copyright Terimber 2003-.