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 504 of file DomainParticipantImpl.h.


Constructor & Destructor Documentation

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

Definition at line 1945 of file DomainParticipantImpl.cpp.

01947   : impl_(impl)
01948   , kind_ (kind)
01949   , interval_ (ACE_Time_Value::max_time)
01950   , recalculate_interval_ (false)
01951   , scheduled_ (false)
01952 { }

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

Definition at line 1954 of file DomainParticipantImpl.cpp.

References scheduled_, and TheServiceParticipant.

01955 {
01956   if (scheduled_) {
01957     TheServiceParticipant->timer()->cancel_timer(this);
01958   }
01959 }


Member Function Documentation

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

Definition at line 1962 of file DomainParticipantImpl.cpp.

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

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

01963 {
01964   ACE_GUARD(ACE_Thread_Mutex,
01965             guard,
01966             this->lock_);
01967 
01968   const ACE_Time_Value now = ACE_OS::gettimeofday();
01969 
01970   // Calculate the time remaining to liveliness check.
01971   const ACE_Time_Value remaining = interval_ - (now - last_liveliness_check_);
01972 
01973   // Adopt a smaller interval.
01974   const ACE_Time_Value i = writer->liveliness_check_interval(kind_);
01975   if (i < interval_) {
01976     interval_ = i;
01977   }
01978 
01979   // Reschedule or schedule a timer if necessary.
01980   if (scheduled_ && interval_ < remaining) {
01981     TheServiceParticipant->timer()->cancel_timer(this);
01982     TheServiceParticipant->timer()->schedule_timer(this, 0, interval_);
01983   } else if (!scheduled_) {
01984     TheServiceParticipant->timer()->schedule_timer(this, 0, interval_);
01985     scheduled_ = true;
01986     last_liveliness_check_ = now;
01987   }
01988 }

virtual void OpenDDS::DCPS::DomainParticipantImpl::LivelinessTimer::dispatch ( const ACE_Time_Value &  tv  )  [pure virtual]

Implemented in OpenDDS::DCPS::DomainParticipantImpl::AutomaticLivelinessTimer, and OpenDDS::DCPS::DomainParticipantImpl::ParticipantLivelinessTimer.

Referenced by handle_timeout().

int OpenDDS::DCPS::DomainParticipantImpl::LivelinessTimer::handle_timeout ( const ACE_Time_Value &  tv,
const void *   
)

Definition at line 2001 of file DomainParticipantImpl.cpp.

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

02002 {
02003   ACE_GUARD_RETURN(ACE_Thread_Mutex,
02004                    guard,
02005                    this->lock_,
02006                    0);
02007 
02008   scheduled_ = false;
02009 
02010   if (recalculate_interval_) {
02011     interval_ = impl_.liveliness_check_interval(kind_);
02012     recalculate_interval_ = false;
02013   }
02014 
02015   if (interval_ != ACE_Time_Value::max_time) {
02016     dispatch(tv);
02017     last_liveliness_check_ = tv;
02018     TheServiceParticipant->timer()->schedule_timer(this, 0, interval_);
02019     scheduled_ = true;
02020   }
02021 
02022   return 0;
02023 }

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

Definition at line 517 of file DomainParticipantImpl.h.

References interval_.

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

00517 { return interval_; }

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

Definition at line 1991 of file DomainParticipantImpl.cpp.

References recalculate_interval_.

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

01992 {
01993   ACE_GUARD(ACE_Thread_Mutex,
01994             guard,
01995             this->lock_);
01996 
01997   recalculate_interval_ = true;
01998 }


Member Data Documentation

DomainParticipantImpl& OpenDDS::DCPS::DomainParticipantImpl::LivelinessTimer::impl_ [protected]

Definition at line 514 of file DomainParticipantImpl.h.

Referenced by OpenDDS::DCPS::DomainParticipantImpl::ParticipantLivelinessTimer::dispatch(), OpenDDS::DCPS::DomainParticipantImpl::AutomaticLivelinessTimer::dispatch(), and handle_timeout().

ACE_Time_Value OpenDDS::DCPS::DomainParticipantImpl::LivelinessTimer::interval_ [private]

Definition at line 520 of file DomainParticipantImpl.h.

Referenced by add_adjust(), and handle_timeout().

const DDS::LivelinessQosPolicyKind OpenDDS::DCPS::DomainParticipantImpl::LivelinessTimer::kind_ [protected]

Definition at line 515 of file DomainParticipantImpl.h.

Referenced by add_adjust(), OpenDDS::DCPS::DomainParticipantImpl::ParticipantLivelinessTimer::dispatch(), OpenDDS::DCPS::DomainParticipantImpl::AutomaticLivelinessTimer::dispatch(), and handle_timeout().

ACE_Time_Value OpenDDS::DCPS::DomainParticipantImpl::LivelinessTimer::last_liveliness_check_ [private]

Definition at line 522 of file DomainParticipantImpl.h.

Referenced by add_adjust(), and handle_timeout().

ACE_Thread_Mutex OpenDDS::DCPS::DomainParticipantImpl::LivelinessTimer::lock_ [private]

Definition at line 524 of file DomainParticipantImpl.h.

bool OpenDDS::DCPS::DomainParticipantImpl::LivelinessTimer::recalculate_interval_ [private]

Definition at line 521 of file DomainParticipantImpl.h.

Referenced by handle_timeout(), and remove_adjust().

bool OpenDDS::DCPS::DomainParticipantImpl::LivelinessTimer::scheduled_ [private]

Definition at line 523 of file DomainParticipantImpl.h.

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


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