00001 // -*- C++ -*- 00002 00003 /** 00004 * @file EC_Timeout_Generator.h 00005 * 00006 * $Id: EC_Timeout_Generator.h 73791 2006-07-27 20:54:56Z wotte $ 00007 * 00008 * @author Carlos O'Ryan (coryan@cs.wustl.edu) 00009 * 00010 * Based on previous work by Tim Harrison (harrison@cs.wustl.edu) and 00011 * other members of the DOC group. More details can be found in: 00012 * 00013 * http://doc.ece.uci.edu/~coryan/EC/index.html 00014 */ 00015 00016 #ifndef TAO_EC_TIMEOUT_GENERATOR_H 00017 #define TAO_EC_TIMEOUT_GENERATOR_H 00018 00019 #include /**/ "ace/pre.h" 00020 #include "ace/Event_Handler.h" 00021 00022 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00023 # pragma once 00024 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00025 00026 #include /**/ "orbsvcs/Event/event_serv_export.h" 00027 00028 #include "orbsvcs/Event/EC_Timeout_Filter.h" 00029 00030 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00031 00032 class TAO_EC_QOS_Info; 00033 00034 /** 00035 * @class TAO_EC_Timeout_Generator 00036 * 00037 * @brief Define the interface for the generators of timeout events. 00038 * 00039 * The Event Channel can use several strategies to dispatch 00040 * timers, for instance, it can use the ORB reactor or a pool of 00041 * reactors running at different priorities or a pool of 00042 * Thread_Timer_Queue_Adapters running at different priorities 00043 * also. 00044 * This class is the abstract base class to abstract this 00045 * strategies. 00046 */ 00047 class TAO_RTEvent_Serv_Export TAO_EC_Timeout_Generator 00048 { 00049 public: 00050 /// destructor 00051 virtual ~TAO_EC_Timeout_Generator (void); 00052 00053 /// Activate any internal threads. 00054 virtual void activate (void) = 0; 00055 00056 /// Deactivate any internal threads, clients can destroy the object 00057 /// after calling this method. 00058 virtual void shutdown (void) = 0; 00059 00060 /// Add a timer at the given priority, returns the timer ID. 00061 virtual int schedule_timer (TAO_EC_Timeout_Filter* filter, 00062 const ACE_Time_Value& delta, 00063 const ACE_Time_Value& interval) = 0; 00064 00065 /// Cancel a timer at the given priority. 00066 virtual int cancel_timer (const TAO_EC_QOS_Info& info, 00067 int id) = 0; 00068 }; 00069 00070 // **************************************************************** 00071 00072 /** 00073 * @class TAO_EC_Timeout_Adapter 00074 * 00075 * @brief Adapt the EC_Filter interface as an Event_Handler. 00076 * 00077 * ACE timer queues (including the reactor) use Event_Handlers to 00078 * dispatch events, but we want to receive them in EC_Filters, 00079 * this class is and adaptor for that purpose. 00080 */ 00081 class TAO_RTEvent_Serv_Export TAO_EC_Timeout_Adapter : public ACE_Event_Handler 00082 { 00083 public: 00084 /// Default construction. 00085 TAO_EC_Timeout_Adapter (void); 00086 00087 private: 00088 /// Casts <act> to EC_Filter and dispatches an event to it. 00089 virtual int handle_timeout (const ACE_Time_Value &tv, 00090 const void *act); 00091 }; 00092 00093 TAO_END_VERSIONED_NAMESPACE_DECL 00094 00095 #if defined (__ACE_INLINE__) 00096 #include "orbsvcs/Event/EC_Timeout_Generator.inl" 00097 #endif /* __ACE_INLINE__ */ 00098 00099 #include /**/ "ace/post.h" 00100 00101 #endif /* TAO_EC_TIMEOUT_GENERATOR_H */