OpenDDS::DCPS::DataLinkWatchdog Class Reference

#include <DataLinkWatchdog_T.h>

Inheritance diagram for OpenDDS::DCPS::DataLinkWatchdog:

Inheritance graph
[legend]
Collaboration diagram for OpenDDS::DCPS::DataLinkWatchdog:

Collaboration graph
[legend]
List of all members.

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_

Classes

class  CancelCommand
class  CommandBase
class  ScheduleCommand

Detailed Description

Definition at line 24 of file DataLinkWatchdog_T.h.


Constructor & Destructor Documentation

OpenDDS::DCPS::DataLinkWatchdog::DataLinkWatchdog ( ACE_Reactor *  reactor,
ACE_thread_t  owner 
) [inline, protected]

Definition at line 73 of file DataLinkWatchdog_T.h.

00075     : ReactorInterceptor(reactor, owner)
00076     , timer_id_(-1)
00077     , cancelled_(false)
00078   {}

virtual OpenDDS::DCPS::DataLinkWatchdog::~DataLinkWatchdog (  )  [inline, protected, virtual]

Definition at line 80 of file DataLinkWatchdog_T.h.

00080                               {
00081   }


Member Function Documentation

void OpenDDS::DCPS::DataLinkWatchdog::cancel (  )  [inline]

Definition at line 39 of file DataLinkWatchdog_T.h.

References OpenDDS::DCPS::ReactorInterceptor::execute_or_enqueue().

Referenced by OpenDDS::DCPS::ReliableSession::stop(), OpenDDS::DCPS::MulticastSession::stop(), OpenDDS::DCPS::MulticastSession::synack_received(), OpenDDS::DCPS::MulticastSession::~MulticastSession(), and OpenDDS::DCPS::ReliableSession::~ReliableSession().

00039                 {
00040     CancelCommand c(this);
00041     execute_or_enqueue(c);
00042   }

void OpenDDS::DCPS::DataLinkWatchdog::cancel_i (  )  [inline, private]

Definition at line 169 of file DataLinkWatchdog_T.h.

References cancelled_, and timer_id_.

Referenced by OpenDDS::DCPS::DataLinkWatchdog::CancelCommand::execute(), and handle_timeout().

00169                   {
00170     if (this->timer_id_ == -1) return;
00171 
00172     this->timer_id_ = -1;
00173     this->cancelled_ = true;
00174     reactor()->cancel_timer(this);
00175   }

int OpenDDS::DCPS::DataLinkWatchdog::handle_timeout ( const ACE_Time_Value &  now,
const void *  arg 
) [inline]

Definition at line 44 of file DataLinkWatchdog_T.h.

References cancel_i(), epoch_, next_timeout(), on_interval(), on_timeout(), and schedule_i().

00044                                                                  {
00045     ACE_Time_Value timeout = next_timeout();
00046 
00047     if (timeout != ACE_Time_Value::zero) {
00048       timeout += this->epoch_;
00049       if (now > timeout) {
00050         on_timeout(arg);
00051         {
00052           cancel_i();
00053         }
00054         return 0;
00055       }
00056     }
00057 
00058     on_interval(arg);
00059 
00060     {
00061       if (!schedule_i(arg, false)) {
00062         ACE_ERROR((LM_WARNING,
00063                    ACE_TEXT("(%P|%t) WARNING: ")
00064                    ACE_TEXT("DataLinkWatchdog::handle_timeout: ")
00065                    ACE_TEXT("unable to reschedule watchdog timer!\n")));
00066       }
00067     }
00068 
00069     return 0;
00070   }

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 86 of file DataLinkWatchdog_T.h.

Referenced by handle_timeout().

00086 { 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 87 of file DataLinkWatchdog_T.h.

Referenced by handle_timeout().

00087 {}

bool OpenDDS::DCPS::DataLinkWatchdog::schedule ( const void *  arg = 0  )  [inline]

Definition at line 27 of file DataLinkWatchdog_T.h.

References OpenDDS::DCPS::ReactorInterceptor::execute_or_enqueue().

00027                                      {
00028     ScheduleCommand c(this, arg, false);
00029     execute_or_enqueue(c);
00030     return true;
00031   }

bool OpenDDS::DCPS::DataLinkWatchdog::schedule_i ( const void *  arg,
bool  nodelay 
) [inline, private]

Definition at line 132 of file DataLinkWatchdog_T.h.

References epoch_, next_interval(), and timer_id_.

Referenced by OpenDDS::DCPS::DataLinkWatchdog::ScheduleCommand::execute(), and handle_timeout().

00132                                                  {
00133     if (this->cancelled_) return true;
00134 
00135     ACE_Time_Value delay;
00136     if (!nodelay) delay = next_interval();
00137 
00138     if (this->epoch_ == ACE_Time_Value::zero) {
00139       this->epoch_ = ACE_OS::gettimeofday();
00140     }
00141 
00142     long timer_id = -1;
00143     {
00144       timer_id = reactor()->schedule_timer(this,  // event_handler
00145                                            arg,
00146                                            delay);
00147 
00148       if (timer_id == -1) {
00149         ACE_ERROR_RETURN ((LM_ERROR,
00150                   ACE_TEXT("(%P|%t) ERROR: ")
00151                   ACE_TEXT("DataLinkWatchdog::schedule_i: ")
00152                   ACE_TEXT("failed to register timer %p!\n"),
00153                   ACE_TEXT("schedule_timer")), false);
00154       }
00155     }
00156 
00157     //after re-acquiring lock_ need to check cancelled_
00158     if (this->cancelled_) {
00159       reactor()->cancel_timer(timer_id);
00160       return true;
00161     }
00162     else {
00163       this->timer_id_ = timer_id;
00164     }
00165 
00166     return this->timer_id_ != -1;
00167   }

bool OpenDDS::DCPS::DataLinkWatchdog::schedule_now ( const void *  arg = 0  )  [inline]

Definition at line 33 of file DataLinkWatchdog_T.h.

References OpenDDS::DCPS::ReactorInterceptor::execute_or_enqueue().

Referenced by OpenDDS::DCPS::MulticastSession::start_syn().

00033                                          {
00034     ScheduleCommand c(this, arg, true);
00035     execute_or_enqueue(c);
00036     return true;
00037   }


Member Data Documentation

bool OpenDDS::DCPS::DataLinkWatchdog::cancelled_ [private]

Definition at line 130 of file DataLinkWatchdog_T.h.

Referenced by cancel_i().

ACE_Time_Value OpenDDS::DCPS::DataLinkWatchdog::epoch_ [private]

Definition at line 129 of file DataLinkWatchdog_T.h.

Referenced by handle_timeout(), and schedule_i().

long OpenDDS::DCPS::DataLinkWatchdog::timer_id_ [private]

Definition at line 127 of file DataLinkWatchdog_T.h.

Referenced by cancel_i(), and schedule_i().


The documentation for this class was generated from the following file:
Generated on Fri Feb 12 20:06:27 2016 for OpenDDS by  doxygen 1.4.7