#include <DataLinkWatchdog_T.h>
Classes | |
class | CancelCommand |
class | CommandBase |
class | ScheduleCommand |
Public Member Functions | |
bool | schedule (const void *arg=0) |
bool | schedule_now (const void *arg=0) |
void | cancel () |
int | handle_timeout (const ACE_Time_Value &now, const void *arg) |
Protected Member Functions | |
DataLinkWatchdog (ACE_Reactor *reactor, ACE_thread_t owner) | |
virtual | ~DataLinkWatchdog () |
virtual ACE_Time_Value | next_interval ()=0 |
virtual void | on_interval (const void *arg)=0 |
virtual ACE_Time_Value | next_timeout () |
virtual void | on_timeout (const void *) |
Private Member Functions | |
bool | schedule_i (const void *arg, bool nodelay) |
void | cancel_i () |
Private Attributes | |
long | timer_id_ |
ACE_Time_Value | epoch_ |
bool | cancelled_ |
Definition at line 26 of file DataLinkWatchdog_T.h.
OpenDDS::DCPS::DataLinkWatchdog::DataLinkWatchdog | ( | ACE_Reactor * | reactor, | |
ACE_thread_t | owner | |||
) | [inline, protected] |
Definition at line 75 of file DataLinkWatchdog_T.h.
00077 : ReactorInterceptor(reactor, owner) 00078 , timer_id_(-1) 00079 , cancelled_(false) 00080 {}
virtual OpenDDS::DCPS::DataLinkWatchdog::~DataLinkWatchdog | ( | ) | [inline, protected, virtual] |
Definition at line 82 of file DataLinkWatchdog_T.h.
void OpenDDS::DCPS::DataLinkWatchdog::cancel | ( | void | ) | [inline] |
Definition at line 41 of file DataLinkWatchdog_T.h.
References c, and OpenDDS::DCPS::ReactorInterceptor::execute_or_enqueue().
00041 { 00042 CancelCommand c(this); 00043 execute_or_enqueue(c); 00044 }
void OpenDDS::DCPS::DataLinkWatchdog::cancel_i | ( | ) | [inline, private] |
Definition at line 171 of file DataLinkWatchdog_T.h.
References ACE_Reactor::cancel_timer(), cancelled_, ACE_Event_Handler::reactor(), and timer_id_.
Referenced by OpenDDS::DCPS::DataLinkWatchdog::CancelCommand::execute(), and handle_timeout().
00171 { 00172 if (this->timer_id_ == -1) return; 00173 00174 this->timer_id_ = -1; 00175 this->cancelled_ = true; 00176 reactor()->cancel_timer(this); 00177 }
int OpenDDS::DCPS::DataLinkWatchdog::handle_timeout | ( | const ACE_Time_Value & | now, | |
const void * | arg | |||
) | [inline, virtual] |
Reimplemented from ACE_Event_Handler.
Definition at line 46 of file DataLinkWatchdog_T.h.
References ACE_TEXT(), cancel_i(), epoch_, LM_WARNING, next_timeout(), on_interval(), on_timeout(), schedule_i(), and ACE_Time_Value::zero.
00046 { 00047 ACE_Time_Value timeout = next_timeout(); 00048 00049 if (timeout != ACE_Time_Value::zero) { 00050 timeout += this->epoch_; 00051 if (now > timeout) { 00052 on_timeout(arg); 00053 { 00054 cancel_i(); 00055 } 00056 return 0; 00057 } 00058 } 00059 00060 on_interval(arg); 00061 00062 { 00063 if (!schedule_i(arg, false)) { 00064 ACE_ERROR((LM_WARNING, 00065 ACE_TEXT("(%P|%t) WARNING: ") 00066 ACE_TEXT("DataLinkWatchdog::handle_timeout: ") 00067 ACE_TEXT("unable to reschedule watchdog timer!\n"))); 00068 } 00069 } 00070 00071 return 0; 00072 }
virtual ACE_Time_Value OpenDDS::DCPS::DataLinkWatchdog::next_interval | ( | ) | [protected, pure virtual] |
Implemented in OpenDDS::DCPS::SynWatchdog, and OpenDDS::DCPS::NakWatchdog.
Referenced by schedule_i().
virtual ACE_Time_Value OpenDDS::DCPS::DataLinkWatchdog::next_timeout | ( | ) | [inline, protected, virtual] |
Reimplemented in OpenDDS::DCPS::SynWatchdog.
Definition at line 88 of file DataLinkWatchdog_T.h.
References ACE_Time_Value::zero.
Referenced by handle_timeout().
00088 { return ACE_Time_Value::zero; }
virtual void OpenDDS::DCPS::DataLinkWatchdog::on_interval | ( | const void * | arg | ) | [protected, pure virtual] |
Implemented in OpenDDS::DCPS::SynWatchdog, and OpenDDS::DCPS::NakWatchdog.
Referenced by handle_timeout().
virtual void OpenDDS::DCPS::DataLinkWatchdog::on_timeout | ( | const void * | ) | [inline, protected, virtual] |
Reimplemented in OpenDDS::DCPS::SynWatchdog.
Definition at line 89 of file DataLinkWatchdog_T.h.
Referenced by handle_timeout().
bool OpenDDS::DCPS::DataLinkWatchdog::schedule | ( | const void * | arg = 0 |
) | [inline] |
Definition at line 29 of file DataLinkWatchdog_T.h.
References c, and OpenDDS::DCPS::ReactorInterceptor::execute_or_enqueue().
00029 { 00030 ScheduleCommand c(this, arg, false); 00031 execute_or_enqueue(c); 00032 return true; 00033 }
bool OpenDDS::DCPS::DataLinkWatchdog::schedule_i | ( | const void * | arg, | |
bool | nodelay | |||
) | [inline, private] |
Definition at line 134 of file DataLinkWatchdog_T.h.
References ACE_TEXT(), ACE_Reactor::cancel_timer(), cancelled_, epoch_, ACE_OS::gettimeofday(), LM_ERROR, next_interval(), ACE_Event_Handler::reactor(), ACE_Reactor::schedule_timer(), timer_id_, and ACE_Time_Value::zero.
Referenced by OpenDDS::DCPS::DataLinkWatchdog::ScheduleCommand::execute(), and handle_timeout().
00134 { 00135 if (this->cancelled_) return true; 00136 00137 ACE_Time_Value delay; 00138 if (!nodelay) delay = next_interval(); 00139 00140 if (this->epoch_ == ACE_Time_Value::zero) { 00141 this->epoch_ = ACE_OS::gettimeofday(); 00142 } 00143 00144 long timer_id = -1; 00145 { 00146 timer_id = reactor()->schedule_timer(this, // event_handler 00147 arg, 00148 delay); 00149 00150 if (timer_id == -1) { 00151 ACE_ERROR_RETURN ((LM_ERROR, 00152 ACE_TEXT("(%P|%t) ERROR: ") 00153 ACE_TEXT("DataLinkWatchdog::schedule_i: ") 00154 ACE_TEXT("failed to register timer %p!\n"), 00155 ACE_TEXT("schedule_timer")), false); 00156 } 00157 } 00158 00159 //after re-acquiring lock_ need to check cancelled_ 00160 if (this->cancelled_) { 00161 reactor()->cancel_timer(timer_id); 00162 return true; 00163 } 00164 else { 00165 this->timer_id_ = timer_id; 00166 } 00167 00168 return this->timer_id_ != -1; 00169 }
bool OpenDDS::DCPS::DataLinkWatchdog::schedule_now | ( | const void * | arg = 0 |
) | [inline] |
Definition at line 35 of file DataLinkWatchdog_T.h.
References c, and OpenDDS::DCPS::ReactorInterceptor::execute_or_enqueue().
00035 { 00036 ScheduleCommand c(this, arg, true); 00037 execute_or_enqueue(c); 00038 return true; 00039 }
bool OpenDDS::DCPS::DataLinkWatchdog::cancelled_ [private] |
Definition at line 132 of file DataLinkWatchdog_T.h.
Referenced by cancel_i(), and schedule_i().
Definition at line 131 of file DataLinkWatchdog_T.h.
Referenced by handle_timeout(), and schedule_i().
long OpenDDS::DCPS::DataLinkWatchdog::timer_id_ [private] |
Definition at line 129 of file DataLinkWatchdog_T.h.
Referenced by cancel_i(), and schedule_i().