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 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL 00023 00024 namespace OpenDDS { 00025 namespace DCPS { 00026 00027 class DataReaderImpl; 00028 00029 /** 00030 * @class RequestedDeadlineWatchdog 00031 * 00032 * @brief Watchdog responsible calling the @c DataReaderListener 00033 * when the deadline period expires. 00034 * 00035 * This watchdog object calls the 00036 * @c on_requested_deadline_missed() listener callback when the 00037 * configured finite deadline period expires. 00038 */ 00039 class RequestedDeadlineWatchdog : 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 RequestedDeadlineWatchdog( 00046 lock_type & lock, 00047 DDS::DeadlineQosPolicy qos, 00048 DataReaderImpl& reader_impl, 00049 DDS::RequestedDeadlineMissedStatus & status, 00050 CORBA::Long & last_total_count); 00051 00052 virtual ~RequestedDeadlineWatchdog(); 00053 00054 /// Schedule timer for the supplied instance. 00055 void schedule_timer(OpenDDS::DCPS::SubscriptionInstance_rch instance); 00056 00057 /// Cancel timer for the supplied instance. 00058 void cancel_timer(OpenDDS::DCPS::SubscriptionInstance_rch instance); 00059 00060 virtual int handle_timeout(const ACE_Time_Value&, const void* act); 00061 00062 /// Operation to be executed when the associated timer expires. 00063 /** 00064 * This @c Watchdog object updates the 00065 * @c DDS::RequestedDeadlineMissed structure, and calls 00066 * @c DataReaderListener::on_requested_deadline_missed(). 00067 */ 00068 void execute(OpenDDS::DCPS::SubscriptionInstance_rch, bool timer_called); 00069 00070 /// Re-schedule timer for all instances of the DataReader. 00071 virtual void reschedule_deadline(); 00072 00073 private: 00074 00075 /// Lock for synchronization of @c status_ member. 00076 lock_type & status_lock_; 00077 /// Reverse lock used for releasing the @c status_lock_ listener upcall. 00078 reverse_lock_type reverse_status_lock_; 00079 00080 /// Pointer to the @c DataReaderImpl object from which the 00081 /// @c DataReaderListener is obtained. 00082 WeakRcHandle<DataReaderImpl> reader_impl_; 00083 00084 /// Reference to the missed requested deadline status 00085 /// structure. 00086 DDS::RequestedDeadlineMissedStatus& status_; 00087 00088 /// Last total_count when status was last checked. 00089 CORBA::Long & last_total_count_; 00090 }; 00091 00092 } // namespace DCPS 00093 } // namespace OpenDDS 00094 00095 OPENDDS_END_VERSIONED_NAMESPACE_DECL 00096 00097 #endif /* OPENDDS_REQUESTED_DEADLINE_WATCHDOG_H */