OpenDDS::DCPS::DomainParticipantImpl::LivelinessTimer Class Reference

Inheritance diagram for OpenDDS::DCPS::DomainParticipantImpl::LivelinessTimer:
Inheritance graph
[legend]
Collaboration diagram for OpenDDS::DCPS::DomainParticipantImpl::LivelinessTimer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 LivelinessTimer (DomainParticipantImpl &impl, DDS::LivelinessQosPolicyKind kind)
virtual ~LivelinessTimer ()
void add_adjust (OpenDDS::DCPS::DataWriterImpl *writer)
void remove_adjust ()
int handle_timeout (const ACE_Time_Value &tv, const void *)
virtual void dispatch (const ACE_Time_Value &tv)=0

Protected Member Functions

ACE_Time_Value interval () const

Protected Attributes

DomainParticipantImplimpl_
const DDS::LivelinessQosPolicyKind kind_

Private Attributes

ACE_Time_Value interval_
bool recalculate_interval_
ACE_Time_Value last_liveliness_check_
bool scheduled_
ACE_Thread_Mutex lock_

Detailed Description

Definition at line 520 of file DomainParticipantImpl.h.


Constructor & Destructor Documentation

OpenDDS::DCPS::DomainParticipantImpl::LivelinessTimer::LivelinessTimer ( DomainParticipantImpl impl,
DDS::LivelinessQosPolicyKind  kind 
)

Definition at line 2214 of file DomainParticipantImpl.cpp.

02216   : impl_(impl)
02217   , kind_ (kind)
02218   , interval_ (ACE_Time_Value::max_time)
02219   , recalculate_interval_ (false)
02220   , scheduled_ (false)
02221 { }

OpenDDS::DCPS::DomainParticipantImpl::LivelinessTimer::~LivelinessTimer (  )  [virtual]

Definition at line 2223 of file DomainParticipantImpl.cpp.

References scheduled_, and TheServiceParticipant.

02224 {
02225   if (scheduled_) {
02226     TheServiceParticipant->timer()->cancel_timer(this);
02227   }
02228 }


Member Function Documentation

void OpenDDS::DCPS::DomainParticipantImpl::LivelinessTimer::add_adjust ( OpenDDS::DCPS::DataWriterImpl writer  ) 

Definition at line 2231 of file DomainParticipantImpl.cpp.

References ACE_OS::gettimeofday(), interval_, kind_, last_liveliness_check_, OpenDDS::DCPS::DataWriterImpl::liveliness_check_interval(), lock_, scheduled_, and TheServiceParticipant.

Referenced by OpenDDS::DCPS::DomainParticipantImpl::add_adjust_liveliness_timers().

02232 {
02233   ACE_GUARD(ACE_Thread_Mutex,
02234             guard,
02235             this->lock_);
02236 
02237   const ACE_Time_Value now = ACE_OS::gettimeofday();
02238 
02239   // Calculate the time remaining to liveliness check.
02240   const ACE_Time_Value remaining = interval_ - (now - last_liveliness_check_);
02241 
02242   // Adopt a smaller interval.
02243   const ACE_Time_Value i = writer->liveliness_check_interval(kind_);
02244   if (i < interval_) {
02245     interval_ = i;
02246   }
02247 
02248   // Reschedule or schedule a timer if necessary.
02249   if (scheduled_ && interval_ < remaining) {
02250     TheServiceParticipant->timer()->cancel_timer(this);
02251     TheServiceParticipant->timer()->schedule_timer(this, 0, interval_);
02252   } else if (!scheduled_) {
02253     TheServiceParticipant->timer()->schedule_timer(this, 0, interval_);
02254     scheduled_ = true;
02255     last_liveliness_check_ = now;
02256   }
02257 }

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void OpenDDS::DCPS::DomainParticipantImpl::LivelinessTimer::dispatch ( const ACE_Time_Value tv  )  [pure virtual]
int OpenDDS::DCPS::DomainParticipantImpl::LivelinessTimer::handle_timeout ( const ACE_Time_Value tv,
const void *   
) [virtual]

Reimplemented from ACE_Event_Handler.

Definition at line 2270 of file DomainParticipantImpl.cpp.

References dispatch(), impl_, interval_, kind_, last_liveliness_check_, OpenDDS::DCPS::DomainParticipantImpl::liveliness_check_interval(), lock_, ACE_Time_Value::max_time, recalculate_interval_, scheduled_, and TheServiceParticipant.

02271 {
02272   ACE_GUARD_RETURN(ACE_Thread_Mutex,
02273                    guard,
02274                    this->lock_,
02275                    0);
02276 
02277   scheduled_ = false;
02278 
02279   if (recalculate_interval_) {
02280     interval_ = impl_.liveliness_check_interval(kind_);
02281     recalculate_interval_ = false;
02282   }
02283 
02284   if (interval_ != ACE_Time_Value::max_time) {
02285     dispatch(tv);
02286     last_liveliness_check_ = tv;
02287     TheServiceParticipant->timer()->schedule_timer(this, 0, interval_);
02288     scheduled_ = true;
02289   }
02290 
02291   return 0;
02292 }

Here is the call graph for this function:

ACE_Time_Value OpenDDS::DCPS::DomainParticipantImpl::LivelinessTimer::interval ( void   )  const [inline, protected]

Definition at line 533 of file DomainParticipantImpl.h.

References interval_.

Referenced by OpenDDS::DCPS::DomainParticipantImpl::ParticipantLivelinessTimer::dispatch().

00533 { return interval_; }

Here is the caller graph for this function:

void OpenDDS::DCPS::DomainParticipantImpl::LivelinessTimer::remove_adjust (  ) 

Definition at line 2260 of file DomainParticipantImpl.cpp.

References lock_, and recalculate_interval_.

Referenced by OpenDDS::DCPS::DomainParticipantImpl::remove_adjust_liveliness_timers().

02261 {
02262   ACE_GUARD(ACE_Thread_Mutex,
02263             guard,
02264             this->lock_);
02265 
02266   recalculate_interval_ = true;
02267 }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 536 of file DomainParticipantImpl.h.

Referenced by add_adjust(), and handle_timeout().

Definition at line 538 of file DomainParticipantImpl.h.

Referenced by add_adjust(), and handle_timeout().

Definition at line 540 of file DomainParticipantImpl.h.

Referenced by add_adjust(), handle_timeout(), and remove_adjust().

Definition at line 537 of file DomainParticipantImpl.h.

Referenced by handle_timeout(), and remove_adjust().

Definition at line 539 of file DomainParticipantImpl.h.

Referenced by add_adjust(), handle_timeout(), and ~LivelinessTimer().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1