OfferedDeadlineWatchdog.h

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 
00008 #ifndef OPENDDS_OFFERED_DEADLINE_WATCHDOG_H
00009 #define OPENDDS_OFFERED_DEADLINE_WATCHDOG_H
00010 
00011 #include "dds/DdsDcpsPublicationC.h"
00012 
00013 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00014 # pragma once
00015 #endif /* ACE_LACKS_PRAGMA_ONCE */
00016 
00017 #include "dds/DCPS/Watchdog.h"
00018 #include "dds/DCPS/PublicationInstance.h"
00019 
00020 #include "ace/Reverse_Lock_T.h"
00021 
00022 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00023 
00024 namespace OpenDDS {
00025 namespace DCPS {
00026 
00027 class DataWriterImpl;
00028 
00029 /**
00030  * @class OfferedDeadlineWatchdog
00031  *
00032  * @brief Watchdog responsible calling the @c DataWriterListener
00033  *        when the deadline period expires.
00034  *
00035  * This watchdog object calls the
00036  * @c on_offered_deadline_missed() listener callback when the
00037  * configured finite deadline period expires.
00038  */
00039 class OfferedDeadlineWatchdog : public Watchdog {
00040 public:
00041 
00042   typedef ACE_Recursive_Thread_Mutex  lock_type;
00043   typedef ACE_Reverse_Lock<lock_type> reverse_lock_type;
00044 
00045   OfferedDeadlineWatchdog(
00046     lock_type & lock,
00047     DDS::DeadlineQosPolicy qos,
00048     OpenDDS::DCPS::DataWriterImpl & writer_impl,
00049     DDS::OfferedDeadlineMissedStatus & status,
00050     CORBA::Long & last_total_count);
00051 
00052   virtual ~OfferedDeadlineWatchdog();
00053 
00054 
00055   virtual int handle_timeout(const ACE_Time_Value&, const void* act);
00056 
00057 
00058   /// Operation to be executed when the associated timer expires.
00059   /**
00060    * This @c Watchdog object updates the
00061    * @c DDS::OfferedDeadlineMissed structure, and calls
00062    * @c DataWriterListener::on_requested_deadline_missed().
00063    */
00064   void execute(DataWriterImpl& writer, PublicationInstance_rch instance, bool timer_called);
00065 
00066   // Schedule timer for the supplied instance.
00067   void schedule_timer(PublicationInstance_rch instance);
00068 
00069   // Cancel timer for the supplied instance.
00070   void cancel_timer(PublicationInstance_rch instance);
00071 
00072   /// Re-schedule timer for all instances of the DataWriter.
00073   virtual void reschedule_deadline();
00074 
00075 private:
00076 
00077   /// Lock for synchronization of @c status_ member.
00078   lock_type & status_lock_;
00079   /// Reverse lock used for releasing the @c status_lock_ listener upcall.
00080   reverse_lock_type reverse_status_lock_;
00081 
00082   /// Pointer to the @c DataWriterImpl object from which the
00083   /// @c DataWriterListener is obtained.
00084   WeakRcHandle<DataWriterImpl>  writer_impl_;
00085 
00086   /// Reference to the missed requested deadline status
00087   /// structure.
00088   DDS::OfferedDeadlineMissedStatus & status_;
00089 
00090   /// Last total_count when status was last checked.
00091   CORBA::Long & last_total_count_;
00092 
00093 };
00094 
00095 } // namespace DCPS
00096 } // namespace OpenDDS
00097 
00098 OPENDDS_END_VERSIONED_NAMESPACE_DECL
00099 
00100 #endif  /* OPENDDS_OFFERED_DEADLINE_WATCHDOG_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1