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 namespace OpenDDS { 00023 namespace DCPS { 00024 00025 class DataWriterImpl; 00026 00027 /** 00028 * @class OfferedDeadlineWatchdog 00029 * 00030 * @brief Watchdog responsible calling the @c DataWriterListener 00031 * when the deadline period expires. 00032 * 00033 * This watchdog object calls the 00034 * @c on_offered_deadline_missed() listener callback when the 00035 * configured finite deadline period expires. 00036 */ 00037 class OfferedDeadlineWatchdog : public Watchdog { 00038 public: 00039 00040 typedef ACE_Recursive_Thread_Mutex lock_type; 00041 typedef ACE_Reverse_Lock<lock_type> reverse_lock_type; 00042 00043 /// Constructor 00044 OfferedDeadlineWatchdog( 00045 lock_type & lock, 00046 DDS::DeadlineQosPolicy qos, 00047 OpenDDS::DCPS::DataWriterImpl * writer_impl, 00048 DDS::DataWriter_ptr writer, 00049 DDS::OfferedDeadlineMissedStatus & status, 00050 CORBA::Long & last_total_count); 00051 00052 /// Destructor 00053 virtual ~OfferedDeadlineWatchdog(); 00054 00055 /// Operation to be executed when the associated timer expires. 00056 /** 00057 * This @c Watchdog object updates the 00058 * @c DDS::OfferedDeadlineMissed structure, and calls 00059 * @c DataWriterListener::on_requested_deadline_missed(). 00060 */ 00061 virtual void execute(void const * act, bool timer_called); 00062 00063 // Schedule timer for the supplied instance. 00064 void schedule_timer(PublicationInstance* instance); 00065 00066 // Cancel timer for the supplied instance. 00067 void cancel_timer(PublicationInstance* instance); 00068 00069 /// Re-schedule timer for all instances of the DataWriter. 00070 virtual void reschedule_deadline(); 00071 00072 private: 00073 00074 /// Lock for synchronization of @c status_ member. 00075 lock_type & status_lock_; 00076 /// Reverse lock used for releasing the @c status_lock_ listener upcall. 00077 reverse_lock_type reverse_status_lock_; 00078 00079 /// Pointer to the @c DataWriterImpl object from which the 00080 /// @c DataWriterListener is obtained. 00081 OpenDDS::DCPS::DataWriterImpl * const writer_impl_; 00082 00083 /// Reference to DataWriter passed to listener when the deadline 00084 /// expires. 00085 DDS::DataWriter_var writer_; 00086 00087 /// Reference to the missed requested deadline status 00088 /// structure. 00089 DDS::OfferedDeadlineMissedStatus & status_; 00090 00091 /// Last total_count when status was last checked. 00092 CORBA::Long & last_total_count_; 00093 00094 }; 00095 00096 } // namespace DCPS 00097 } // namespace OpenDDS 00098 00099 #endif /* OPENDDS_OFFERED_DEADLINE_WATCHDOG_H */