![]() |
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 [] |
void protlib::TimerModule::TimerModule::TimerMap::clear | ( | bool | dispose = true |
) | [inherited] |
clear all
Definition at line 575 of file timer_module.cpp.
References protlib::TimerModule::TimerModule::TimerMap::mid2tid, protlib::TimerModule::TimerModule::TimerMap::tid2mid, and protlib::TimerModule::TimerModule::TimerMap::tid2msg.
Referenced by protlib::TimerModule::stop_all_timers(), and protlib::TimerModule::TimerModule().
void protlib::TimerModule::TimerModule::TimerMap::erase | ( | timer_id_t | tid, | |
message::id_t | mid, | |||
bool | dispose = true | |||
) | [inherited] |
erase record of timer ID and message ID
Please be sure that timer ID and message ID are bound to the same timer. No checking is done!
Definition at line 562 of file timer_module.cpp.
References protlib::TimerModule::TimerModule::TimerMap::lookup_msg(), protlib::TimerModule::TimerModule::TimerMap::mid2tid, protlib::TimerModule::TimerModule::TimerMap::tid2mid, and protlib::TimerModule::TimerModule::TimerMap::tid2msg.
Referenced by protlib::TimerModule::stop_timer(), and protlib::TimerModule::timer_expired().
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.
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().
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] |
Definition at line 520 of file timer_module.cpp.
References protlib::message::get_id(), protlib::TimerModule::TimerModule::TimerMap::mid2tid, protlib::TimerModule::TimerModule::TimerMap::tid2mid, and protlib::TimerModule::TimerModule::TimerMap::tid2msg.
Referenced by protlib::TimerModule::start_timer().
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] |
wait for incoming messages
Wait for incomming mesages and evaluate message action. Messages are accepted until the module is asked to stop.
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.
Definition at line 241 of file timer_module.cpp.
References protlib::TimerMsg::ac_ignore, protlib::TimerMsg::ac_restart, protlib::TimerMsg::ac_start, protlib::TimerMsg::ac_stop, protlib::TimerMsg::ac_stop_all, protlib::log::DEBUG_LOG, protlib::FastQueue::dequeue_timedwait(), ERRLog, protlib::log::ERROR_LOG, protlib::Thread::fq, protlib::TimerMsg::get_action(), protlib::message::get_id(), protlib::message::get_qaddr_name(), protlib::QueueManager::get_queue(), protlib::Thread::get_state(), protlib::message::get_type(), protlib::message::get_type_name(), protlib::QueueManager::instance(), protlib::TimerMsg::is_ok(), protlib::Thread::lock(), Log, protlib::log::LOG_ALERT, protlib::log::LOG_UNIMP, protlib::ThreadParam::name, protlib::message::qaddr_timer, protlib::TimerModule::restart_timer(), protlib::TimerModule::send_error_or_dispose(), protlib::ThreadParam::sleep_time, protlib::TimerModuleParam::source, protlib::TimerModule::start_timer(), protlib::Thread::STATE_RUN, protlib::TimerModule::stop_all_timers(), protlib::TimerModule::stop_timer(), protlib::TimerModule::timerparam, protlib::message::type_timer, and protlib::Thread::unlock().
Referenced by protlib::TimerModule::main_loop().
restart timer
restart timer please note that this method actually overwrites the id of the message(!)
Definition at line 113 of file timer_module.cpp.
References protlib::TimerMsg::ac_ignore, protlib::TimerMsg::ac_restart, protlib::TimerMsg::action, protlib::TimerMsg::ok, protlib::TimerMsg::relative, protlib::message::set_id(), protlib::TimerMsg::time_msec, and protlib::TimerMsg::time_sec.
Referenced by protlib::TimerMsg::restart_absolute(), protlib::TimerMsg::restart_relative(), and protlib::TimerModule::restart_timer().
restart absolute timer
Restart an absolute timer.
Definition at line 101 of file timer_module.cpp.
References protlib::TimerMsg::restart().
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] |
restart a timer
Restarts a timer and stores its ID and the reply message in the hash maps.
Definition at line 363 of file timer_module.cpp.
References DLog, ERRLog, protlib::message::get_id(), protlib::message::get_qaddr_name(), protlib::TimerMsg::get_time(), protlib::TimerMsg::is_relative(), protlib::TimerModule::TimerModule::TimerMap::lookup_msg(), protlib::TimerModule::TimerModule::TimerMap::lookup_tid(), protlib::ThreadParam::name, protlib::TimerMsg::restart(), protlib::TimerManager::restart_absolute(), protlib::TimerManager::restart_relative(), protlib::TimerModule::timerparam, protlib::TimerModule::tm, and protlib::TimerModule::tmap.
Referenced by protlib::TimerModule::process_queue().
void protlib::TimerModule::send_error_or_dispose | ( | TimerMsg * | m, | |
bool | ok | |||
) | [private, inherited] |
send back error
Send back error message. If no error is necessary, the message is disposed.
m | message that is changed to an error message if its flags are set appropriately. | |
ok | success or error? |
Definition at line 450 of file timer_module.cpp.
References protlib::TimerMsg::ac_start, protlib::log::DEBUG_LOG, ERRLog, protlib::TimerMsg::get_action(), protlib::message::get_id(), protlib::message::get_qaddr_name(), protlib::TimerMsg::get_send_error(), protlib::message::get_source(), Log, protlib::log::LOG_UNIMP, protlib::ThreadParam::name, protlib::message::send(), protlib::TimerModuleParam::send_error_expedited, protlib::TimerMsg::set_ok(), protlib::TimerModuleParam::source, and protlib::TimerModule::timerparam.
Referenced by protlib::TimerModule::process_queue().
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] |
start timer
Definition at line 89 of file timer_module.cpp.
References protlib::TimerMsg::ac_start, protlib::TimerMsg::action, protlib::TimerMsg::ok, protlib::TimerMsg::param1, protlib::TimerMsg::param2, protlib::TimerMsg::relative, protlib::TimerMsg::time_msec, and protlib::TimerMsg::time_sec.
Referenced by protlib::TimerMsg::start_absolute(), and protlib::TimerMsg::start_relative().
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] |
start a timer
Starts a timer and stores its ID and the reply message in the hash maps.
Definition at line 325 of file timer_module.cpp.
References ERRLog, protlib::log::EVENT_LOG, protlib::message::get_id(), protlib::message::get_qaddr_name(), protlib::TimerMsg::get_time(), protlib::TimerModule::TimerModule::TimerMap::insert(), protlib::TimerMsg::is_relative(), Log, protlib::log::LOG_UNIMP, protlib::TimerModule::TimerModule::TimerMap::lookup_tid(), protlib::ThreadParam::name, protlib::TimerManager::start_absolute(), protlib::TimerManager::start_relative(), protlib::TimerModule::timerparam, protlib::TimerModule::tm, and protlib::TimerModule::tmap.
Referenced by protlib::TimerModule::process_queue().
bool protlib::TimerMsg::stop | ( | id_t | id | ) | [inherited] |
stop timer
Stop a timer.
Definition at line 130 of file timer_module.cpp.
References protlib::TimerMsg::ac_ignore, protlib::TimerMsg::ac_stop, protlib::TimerMsg::action, protlib::TimerMsg::ok, protlib::TimerMsg::param1, protlib::TimerMsg::param2, protlib::TimerMsg::relative, protlib::message::set_id(), protlib::TimerMsg::time_msec, and protlib::TimerMsg::time_sec.
bool protlib::TimerMsg::stop_all | ( | ) | [inherited] |
stop all timers
Stop all running timers.
Definition at line 146 of file timer_module.cpp.
References protlib::TimerMsg::ac_stop_all, protlib::TimerMsg::action, protlib::TimerMsg::ok, protlib::TimerMsg::param1, protlib::TimerMsg::param2, protlib::TimerMsg::relative, protlib::TimerMsg::time_msec, and protlib::TimerMsg::time_sec.
bool protlib::TimerModule::stop_all_timers | ( | ) | [private, inherited] |
stop all timers
Stop all timers and clear the hash maps.
Definition at line 434 of file timer_module.cpp.
References protlib::TimerModule::TimerModule::TimerMap::clear(), protlib::log::DEBUG_LOG, Log, protlib::log::LOG_UNIMP, protlib::ThreadParam::name, protlib::TimerManager::stop_all(), protlib::TimerModule::timerparam, protlib::TimerModule::tm, and protlib::TimerModule::tmap.
Referenced by protlib::TimerModule::process_queue(), and protlib::TimerModule::~TimerModule().
bool protlib::TimerModule::stop_timer | ( | TimerMsg * | m | ) | [private, inherited] |
stop a timer
Stop a timer and remove its ID and reply message from the hash maps.
Definition at line 403 of file timer_module.cpp.
References DLog, protlib::TimerModule::TimerModule::TimerMap::erase(), ERRLog, protlib::message::get_id(), protlib::message::get_qaddr_name(), protlib::TimerModule::TimerModule::TimerMap::lookup_tid(), protlib::ThreadParam::name, protlib::TimerManager::stop(), protlib::TimerModule::timerparam, protlib::TimerModule::tm, and protlib::TimerModule::tmap.
Referenced by protlib::TimerModule::process_queue().
void protlib::TimerModule::timer_expired | ( | timer_id_t | timer, | |
timer_callback_param_t | callback_param | |||
) | [virtual, inherited] |
callback member function
timer | timer ID | |
callback_param | additional callback parameter. |
timer | timer ID | |
callback_param | additional callback parameter. |
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] |
constructor
Set parameters.
Definition at line 207 of file timer_module.cpp.
References protlib::TimerModule::TimerModule::TimerMap::clear(), DLog, protlib::Thread::get_fqueue(), protlib::QueueManager::instance(), protlib::ThreadParam::name, protlib::QueueManager::register_queue(), protlib::TimerModuleParam::source, protlib::TimerModule::timerparam, and protlib::TimerModule::tmap.
protlib::TimerModuleParam::TimerModuleParam | ( | uint32 | sleep_time = ThreadParam::default_sleep_time , |
|
bool | sua = false , |
|||
bool | see = true , |
|||
bool | sre = true | |||
) | [inherited] |
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] |
protlib::TimerModule::~TimerModule | ( | ) | [virtual, inherited] |
destructor
Stop all running timers.
Definition at line 216 of file timer_module.cpp.
References DLog, protlib::QueueManager::instance(), protlib::ThreadParam::name, protlib::TimerModuleParam::source, protlib::TimerModule::stop_all_timers(), protlib::TimerModule::timerparam, and protlib::QueueManager::unregister_queue().
protlib::TimerMsg::~TimerMsg | ( | ) | [virtual, inherited] |
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().