Timer Module

Collaboration diagram for Timer Module:

Classes

class  protlib::TimerMsg
 timer message More...
struct  protlib::TimerModuleParam
 timer module parameters More...
class  protlib::TimerModule
 timer module class More...

Namespaces

namespace  protlib

Functions

 protlib::TimerMsg::TimerMsg (qaddr_t s=qaddr_unknown, bool s_err=false)
 constructor
virtual protlib::TimerMsg::~TimerMsg ()
 destructor
bool protlib::TimerMsg::set_ok (bool r)
 set result
bool protlib::TimerMsg::start_absolute (int32 sec, int32 msec=0, param_t p1=NULL, param_t p2=NULL)
 start absolute timer
bool protlib::TimerMsg::start_relative (int32 sec, int32 msec=0, param_t p1=NULL, param_t p2=NULL)
 start relative timer
bool protlib::TimerMsg::start (bool rel, int32 sec, int32 msec=0, param_t p1=NULL, param_t p2=NULL)
 start timer
bool protlib::TimerMsg::restart_absolute (id_t id, int32 sec, int32 msec=0)
 restart absolute timer
bool protlib::TimerMsg::restart_relative (id_t id, int32 sec, int32 msec=0)
 restart relative timer
bool protlib::TimerMsg::restart (bool rel, id_t id, int32 sec, int32 msec=0)
 restart timer
bool protlib::TimerMsg::stop (id_t id)
 stop timer
bool protlib::TimerMsg::stop_all ()
 stop all timers
bool protlib::TimerMsg::set_elapsed ()
 set to elapsed
bool protlib::TimerMsg::get_send_error () const
 get send_error flag
bool protlib::TimerMsg::set_send_error (bool f)
 set send_error flag
param_t protlib::TimerMsg::get_param1 () const
 get timer parameter #1
param_t protlib::TimerMsg::get_param2 () const
 get timer parameter #2
void protlib::TimerMsg::get_params (param_t &p1, param_t &p2) const
 get timer parameters
bool protlib::TimerMsg::is_absolute () const
 Is it an absolute or relative timer?
bool protlib::TimerMsg::is_relative () const
 Is it an absolute or relative timer?
 protlib::TimerModuleParam::TimerModuleParam (uint32 sleep_time=ThreadParam::default_sleep_time, bool sua=false, bool ser=true, bool sre=true)
 protlib::TimerModule::TimerModule (const TimerModuleParam &p)
 constructor
virtual protlib::TimerModule::~TimerModule ()
 destructor
virtual void protlib::TimerModule::main_loop (uint32 nr)
 timer module main loop
void protlib::TimerModule::process_queue ()
 wait for incoming messages
void protlib::TimerModule::process_elapsed_timers ()
 check timers and send messages
bool protlib::TimerModule::start_timer (TimerMsg *m)
 start a timer
bool protlib::TimerModule::restart_timer (TimerMsg *m)
 restart a timer
bool protlib::TimerModule::stop_timer (TimerMsg *m)
 stop a timer
bool protlib::TimerModule::stop_all_timers ()
 stop all timers
void protlib::TimerModule::send_error_or_dispose (TimerMsg *m, bool ok)
 send back error
virtual void protlib::TimerModule::timer_expired (timer_id_t timer, timer_callback_param_t callback_param)
 callback member function
bool protlib::TimerModule::TimerMap::insert (timer_id_t tid, TimerMsg *m)
message::id_t protlib::TimerModule::TimerMap::lookup_mid (timer_id_t tid) const
 lookup message ID
timer_id_t protlib::TimerModule::TimerMap::lookup_tid (message::id_t mid) const
 lookup timer ID
TimerMsg * protlib::TimerModule::TimerMap::lookup_msg (timer_id_t tid) const
 lookup message
void protlib::TimerModule::TimerMap::erase (timer_id_t tid, message::id_t mid, bool dispose=true)
 erase record of timer ID and message ID
void protlib::TimerModule::TimerMap::clear (bool dispose=true)
 clear all
void protlib::TimerMsg::get_time (int32 &sec, int32 &msec)
 get alarm
action_t protlib::TimerMsg::get_action () const
 get action
const char * protlib::TimerMsg::get_action_str () const
 get action str
bool protlib::TimerMsg::is_ok ()
 get result

Variables

static const char *const protlib::action_t_str []

Function Documentation

void protlib::TimerModule::TimerModule::TimerMap::clear ( bool  dispose = true  )  [inherited]

void protlib::TimerModule::TimerModule::TimerMap::erase ( timer_id_t  tid,
message::id_t  mid,
bool  dispose = true 
) [inherited]

TimerMsg::action_t protlib::TimerMsg::get_action (  )  const [inline, inherited]

get action

Get timer message action. There is no way to set the action value, this is done by start_relative or start_absolute...

Definition at line 162 of file timer_module.h.

References protlib::TimerMsg::action.

Referenced by protlib::TimerModule::process_queue(), and protlib::TimerModule::send_error_or_dispose().

const char * protlib::TimerMsg::get_action_str (  )  const [inline, inherited]

get action str

Definition at line 169 of file timer_module.h.

References protlib::TimerMsg::action, and protlib::action_t_str.

TimerMsg::param_t protlib::TimerMsg::get_param1 (  )  const [inherited]

get timer parameter #1

Definition at line 177 of file timer_module.cpp.

References protlib::TimerMsg::param1.

TimerMsg::param_t protlib::TimerMsg::get_param2 (  )  const [inherited]

get timer parameter #2

Definition at line 179 of file timer_module.cpp.

References protlib::TimerMsg::param2.

void protlib::TimerMsg::get_params ( param_t p1,
param_t p2 
) const [inherited]

get timer parameters

Definition at line 181 of file timer_module.cpp.

References protlib::TimerMsg::param1, and protlib::TimerMsg::param2.

bool protlib::TimerMsg::get_send_error (  )  const [inherited]

get send_error flag

Definition at line 166 of file timer_module.cpp.

References protlib::TimerMsg::send_error.

Referenced by protlib::TimerModule::send_error_or_dispose().

void protlib::TimerMsg::get_time ( int32 sec,
int32 msec 
) [inline, inherited]

get alarm

Get alarm time. Please check message action to see if this is an absolute or relative time. If this is a expiration notification, the time is absolute.

Definition at line 151 of file timer_module.h.

References protlib::TimerMsg::time_msec, and protlib::TimerMsg::time_sec.

Referenced by protlib::TimerModule::restart_timer(), and protlib::TimerModule::start_timer().

bool protlib::TimerModule::TimerModule::TimerMap::insert ( timer_id_t  tid,
TimerMsg m 
) [inherited]

bool protlib::TimerMsg::is_absolute (  )  const [inherited]

Is it an absolute or relative timer?

Definition at line 186 of file timer_module.cpp.

References protlib::TimerMsg::relative.

bool protlib::TimerMsg::is_ok (  )  [inline, inherited]

get result

Get result flag.

Definition at line 177 of file timer_module.h.

References protlib::TimerMsg::ok.

Referenced by protlib::TimerModule::process_queue().

bool protlib::TimerMsg::is_relative (  )  const [inherited]

Is it an absolute or relative timer?

Definition at line 188 of file timer_module.cpp.

References protlib::TimerMsg::relative.

Referenced by protlib::TimerModule::restart_timer(), and protlib::TimerModule::start_timer().

message::id_t protlib::TimerModule::TimerModule::TimerMap::lookup_mid ( timer_id_t  tid  )  const [inherited]

lookup message ID

Returns the message ID of the timer bound to timer ID or 0 if not found, since every timer must have an ID <> 0.

Definition at line 533 of file timer_module.cpp.

References protlib::TimerModule::TimerModule::TimerMap::tid2mid.

TimerMsg * protlib::TimerModule::TimerModule::TimerMap::lookup_msg ( timer_id_t  tid  )  const [inherited]

lookup message

Returns the timer message of the timer bound to timer ID or NULL if not found.

Definition at line 552 of file timer_module.cpp.

References protlib::TimerModule::TimerModule::TimerMap::tid2msg.

Referenced by protlib::TimerModule::TimerModule::TimerMap::erase(), protlib::TimerModule::restart_timer(), and protlib::TimerModule::timer_expired().

timer_id_t protlib::TimerModule::TimerModule::TimerMap::lookup_tid ( message::id_t  mid  )  const [inherited]

lookup timer ID

Returns the timer-ID of the timer bound to the message ID or 0 if not found, since 0 is never used as a timer ID.

Definition at line 543 of file timer_module.cpp.

References protlib::TimerModule::TimerModule::TimerMap::mid2tid.

Referenced by protlib::TimerModule::restart_timer(), protlib::TimerModule::start_timer(), and protlib::TimerModule::stop_timer().

void protlib::TimerModule::main_loop ( uint32  nr  )  [virtual, inherited]

timer module main loop

Devide Threads in thos which process the queue and those which process expired timers.

Implements protlib::Thread.

Definition at line 226 of file timer_module.cpp.

References protlib::log::INFO_LOG, Log, protlib::log::LOG_NORMAL, protlib::ThreadParam::name, protlib::TimerModule::process_elapsed_timers(), protlib::TimerModule::process_queue(), and protlib::TimerModule::timerparam.

void protlib::TimerModule::process_elapsed_timers (  )  [private, inherited]

check timers and send messages

Check if timers expired and send reply messages. Reply messages are sent until the module is asked to abort if the flag send_until_abort is set true. Otherwise no messages are sent after a stop request.

Definition at line 310 of file timer_module.cpp.

References protlib::TimerManager::check_timers_wait(), protlib::log::DEBUG_LOG, protlib::Thread::get_state(), Log, protlib::log::LOG_UNIMP, protlib::ThreadParam::name, protlib::TimerModuleParam::send_until_abort, protlib::ThreadParam::sleep_time, protlib::Thread::STATE_ABORT, protlib::Thread::STATE_STOP, protlib::TimerModule::timerparam, and protlib::TimerModule::tm.

Referenced by protlib::TimerModule::main_loop().

void protlib::TimerModule::process_queue (  )  [private, inherited]

bool protlib::TimerMsg::restart ( bool  rel,
id_t  id,
int32  sec,
int32  msec = 0 
) [inherited]

bool protlib::TimerMsg::restart_absolute ( id_t  id,
int32  sec,
int32  msec = 0 
) [inherited]

restart absolute timer

Restart an absolute timer.

Definition at line 101 of file timer_module.cpp.

References protlib::TimerMsg::restart().

bool protlib::TimerMsg::restart_relative ( id_t  id,
int32  sec,
int32  msec = 0 
) [inherited]

restart relative timer

Restart a relative timer.

Definition at line 106 of file timer_module.cpp.

References protlib::TimerMsg::restart().

bool protlib::TimerModule::restart_timer ( TimerMsg m  )  [private, inherited]

void protlib::TimerModule::send_error_or_dispose ( TimerMsg m,
bool  ok 
) [private, inherited]

bool protlib::TimerMsg::set_elapsed (  )  [inherited]

set to elapsed

Prepare message for sending it back as a reply message from the TimerModule when its timer expires.

Definition at line 159 of file timer_module.cpp.

References protlib::TimerMsg::ac_elapsed, protlib::TimerMsg::action, protlib::TimerMsg::ok, and protlib::TimerMsg::send_error.

Referenced by protlib::TimerModule::timer_expired().

bool protlib::TimerMsg::set_ok ( bool  r  )  [inherited]

set result

Set result flag and get old value. You should not set this, this is done by the timer module.

Definition at line 73 of file timer_module.cpp.

References protlib::TimerMsg::ok.

Referenced by protlib::TimerModule::send_error_or_dispose().

bool protlib::TimerMsg::set_send_error ( bool  f  )  [inherited]

set send_error flag

Set send_error flag and return old value.

Definition at line 171 of file timer_module.cpp.

References protlib::TimerMsg::send_error.

bool protlib::TimerMsg::start ( bool  rel,
int32  sec,
int32  msec = 0,
param_t  p1 = NULL,
param_t  p2 = NULL 
) [inherited]

bool protlib::TimerMsg::start_absolute ( int32  sec,
int32  msec = 0,
param_t  p1 = NULL,
param_t  p2 = NULL 
) [inherited]

start absolute timer

Prepare message to start an absolute timer.

Definition at line 80 of file timer_module.cpp.

References protlib::TimerMsg::start().

bool protlib::TimerMsg::start_relative ( int32  sec,
int32  msec = 0,
param_t  p1 = NULL,
param_t  p2 = NULL 
) [inherited]

start relative timer

Prepare message to start a relative timer.

Definition at line 85 of file timer_module.cpp.

References protlib::TimerMsg::start().

bool protlib::TimerModule::start_timer ( TimerMsg m  )  [private, inherited]

bool protlib::TimerMsg::stop ( id_t  id  )  [inherited]

bool protlib::TimerMsg::stop_all (  )  [inherited]

bool protlib::TimerModule::stop_all_timers (  )  [private, inherited]

bool protlib::TimerModule::stop_timer ( TimerMsg m  )  [private, inherited]

void protlib::TimerModule::timer_expired ( timer_id_t  timer,
timer_callback_param_t  callback_param 
) [virtual, inherited]

callback member function

Parameters:
timer timer ID
callback_param additional callback parameter.
This is the callback for the TimerManager used by the TimerModule object.
Parameters:
timer timer ID
callback_param additional callback parameter.
The module mutex inherited from the Thread base class is locked here, so all called member functions are called inside a critical section if necessary.

Implements protlib::TimerCallback.

Definition at line 488 of file timer_module.cpp.

References protlib::log::DEBUG_LOG, DLog, protlib::TimerModule::TimerModule::TimerMap::erase(), ERRLog, protlib::message::get_id(), protlib::message::get_qaddr_name(), protlib::message::get_source(), protlib::Thread::lock(), Log, protlib::log::LOG_UNIMP, protlib::TimerModule::TimerModule::TimerMap::lookup_msg(), protlib::ThreadParam::name, protlib::message::send_back(), protlib::TimerModuleParam::send_reply_expedited, protlib::TimerMsg::set_elapsed(), protlib::TimerModuleParam::source, protlib::TimerModule::timerparam, protlib::TimerModule::tmap, and protlib::Thread::unlock().

protlib::TimerModule::TimerModule ( const TimerModuleParam p  )  [inherited]

protlib::TimerModuleParam::TimerModuleParam ( uint32  sleep_time = ThreadParam::default_sleep_time,
bool  sua = false,
bool  see = true,
bool  sre = true 
) [inherited]

Parameters:
sleep_time default sleep time
sua send messages until aborted or just until stopped
see send error messages as expedited data
sre send reply messages as expedited data

Definition at line 197 of file timer_module.cpp.

protlib::TimerMsg::TimerMsg ( qaddr_t  s = qaddr_unknown,
bool  s_err = false 
) [inherited]

constructor

Definition at line 52 of file timer_module.cpp.

protlib::TimerModule::~TimerModule (  )  [virtual, inherited]

protlib::TimerMsg::~TimerMsg (  )  [virtual, inherited]

destructor

Destructor, does nothing.

Definition at line 67 of file timer_module.cpp.


Variable Documentation

const char* const protlib::action_t_str[] [static]

Initial value:

    {
      "ignore",
      "start",
      "restart",
      "stop",
      "stop all",
      "elapsed",
      "unkown"
    }

Definition at line 52 of file timer_module.h.

Referenced by protlib::TimerMsg::get_action_str().


Generated on Fri Aug 14 23:38:38 2009 for Ariba by  doxygen 1.5.8