00001 /* 00002 * 00003 * 00004 * Distributed under the OpenDDS License. 00005 * See: http://www.opendds.org/license.html 00006 */ 00007 00008 #ifndef OPENDDS_REQUESTED_DEADLINE_WATCHDOG_H 00009 #define OPENDDS_REQUESTED_DEADLINE_WATCHDOG_H 00010 00011 #include "dds/DdsDcpsSubscriptionC.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/SubscriptionInstance.h" 00019 00020 #include "ace/Reverse_Lock_T.h" 00021 00022 namespace OpenDDS { 00023 namespace DCPS { 00024 00025 class DataReaderImpl; 00026 00027 /** 00028 * @class RequestedDeadlineWatchdog 00029 * 00030 * @brief Watchdog responsible calling the @c DataReaderListener 00031 * when the deadline period expires. 00032 * 00033 * This watchdog object calls the 00034 * @c on_requested_deadline_missed() listener callback when the 00035 * configured finite deadline period expires. 00036 */ 00037 class RequestedDeadlineWatchdog : 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 RequestedDeadlineWatchdog( 00045 lock_type & lock, 00046 DDS::DeadlineQosPolicy qos, 00047 OpenDDS::DCPS::DataReaderImpl * reader_impl, 00048 DDS::DataReader_ptr reader, 00049 DDS::RequestedDeadlineMissedStatus & status, 00050 CORBA::Long & last_total_count); 00051 00052 /// Destructor 00053 virtual ~RequestedDeadlineWatchdog(); 00054 00055 // Schedule timer for the supplied instance. 00056 void schedule_timer(OpenDDS::DCPS::SubscriptionInstance* instance); 00057 00058 // Cancel timer for the supplied instance. 00059 void cancel_timer(OpenDDS::DCPS::SubscriptionInstance* instance); 00060 00061 /// Operation to be executed when the associated timer expires. 00062 /** 00063 * This @c Watchdog object updates the 00064 * @c DDS::RequestedDeadlineMissed structure, and calls 00065 * @c DataReaderListener::on_requested_deadline_missed(). 00066 */ 00067 virtual void execute(void const * act, bool timer_called); 00068 00069 /// Re-schedule timer for all instances of the DataReader. 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 DataReaderImpl object from which the 00080 /// @c DataReaderListener is obtained. 00081 OpenDDS::DCPS::DataReaderImpl* const reader_impl_; 00082 00083 /// Reference to DataReader passed to listener when the deadline 00084 /// expires. 00085 DDS::DataReader_var reader_; 00086 00087 /// Reference to the missed requested deadline status 00088 /// structure. 00089 DDS::RequestedDeadlineMissedStatus& status_; 00090 00091 /// Last total_count when status was last checked. 00092 CORBA::Long & last_total_count_; 00093 }; 00094 00095 } // namespace DCPS 00096 } // namespace OpenDDS 00097 00098 #endif /* OPENDDS_REQUESTED_DEADLINE_WATCHDOG_H */