00001 // CEC_Dispatching_Task.h,v 1.20 2006/03/14 06:14:24 jtc Exp 00002 // -*- C++ -*- 00003 00004 //============================================================================= 00005 /** 00006 * @file CEC_Dispatching_Task.h 00007 * 00008 * CEC_Dispatching_Task.h,v 1.20 2006/03/14 06:14:24 jtc Exp 00009 * 00010 * @author Carlos O'Ryan (coryan@cs.wustl.edu) 00011 */ 00012 //============================================================================= 00013 00014 00015 #ifndef TAO_CEC_DISPATCHING_TASK_H 00016 #define TAO_CEC_DISPATCHING_TASK_H 00017 00018 #include /**/ "ace/pre.h" 00019 00020 #include "orbsvcs/CosEvent/event_serv_export.h" 00021 00022 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00023 # pragma once 00024 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00025 00026 #include "orbsvcs/CosEvent/CEC_ProxyPushSupplier.h" 00027 00028 #include "tao/Basic_Types.h" 00029 00030 #include "ace/Message_Block.h" 00031 #include "ace/Lock_Adapter_T.h" 00032 #include "ace/Task.h" 00033 00034 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL) 00035 #include "orbsvcs/CosEvent/CEC_TypedEvent.h" 00036 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ 00037 00038 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00039 00040 /** 00041 * @class TAO_CEC_Dispatching_Task 00042 * 00043 * @brief Implement the dispatching queues for FIFO and Priority 00044 * dispatching. 00045 * 00046 */ 00047 class TAO_Event_Serv_Export TAO_CEC_Dispatching_Task : public ACE_Task<ACE_SYNCH> 00048 { 00049 public: 00050 /// Constructor 00051 TAO_CEC_Dispatching_Task (ACE_Thread_Manager* thr_manager = 0); 00052 00053 /// Process the events in the queue. 00054 virtual int svc (void); 00055 00056 virtual void push (TAO_CEC_ProxyPushSupplier *proxy, 00057 CORBA::Any& event 00058 ACE_ENV_ARG_DECL); 00059 00060 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL) 00061 virtual void invoke (TAO_CEC_ProxyPushSupplier *proxy, 00062 TAO_CEC_TypedEvent& typed_event 00063 ACE_ENV_ARG_DECL); 00064 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ 00065 00066 private: 00067 /// An per-task allocator 00068 ACE_Allocator *allocator_; 00069 00070 /// Helper data structure to minimize memory allocations... 00071 ACE_Locked_Data_Block<ACE_Lock_Adapter<TAO_SYNCH_MUTEX> > data_block_; 00072 }; 00073 00074 // **************************************************************** 00075 00076 class TAO_Event_Serv_Export TAO_CEC_Dispatch_Command : public ACE_Message_Block 00077 { 00078 public: 00079 /// Constructor, it will allocate its own data block 00080 TAO_CEC_Dispatch_Command (ACE_Allocator *mb_allocator = 0); 00081 00082 /// Constructor, it assumes ownership of the data block 00083 TAO_CEC_Dispatch_Command (ACE_Data_Block*, 00084 ACE_Allocator *mb_allocator = 0); 00085 00086 /// Destructor 00087 virtual ~TAO_CEC_Dispatch_Command (void); 00088 00089 /// Command callback 00090 virtual int execute (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) = 0; 00091 }; 00092 00093 // **************************************************************** 00094 00095 class TAO_Event_Serv_Export TAO_CEC_Shutdown_Task_Command : public TAO_CEC_Dispatch_Command 00096 { 00097 public: 00098 /// Constructor 00099 TAO_CEC_Shutdown_Task_Command (ACE_Allocator *mb_allocator = 0); 00100 00101 /// Command callback 00102 virtual int execute (ACE_ENV_SINGLE_ARG_DECL_NOT_USED); 00103 }; 00104 00105 // **************************************************************** 00106 00107 class TAO_Event_Serv_Export TAO_CEC_Push_Command : public TAO_CEC_Dispatch_Command 00108 { 00109 public: 00110 /// Constructor 00111 TAO_CEC_Push_Command (TAO_CEC_ProxyPushSupplier* proxy, 00112 CORBA::Any& event, 00113 ACE_Data_Block* data_block, 00114 ACE_Allocator *mb_allocator); 00115 00116 /// Destructor 00117 virtual ~TAO_CEC_Push_Command (void); 00118 00119 /// Command callback 00120 virtual int execute (ACE_ENV_SINGLE_ARG_DECL_NOT_USED); 00121 00122 private: 00123 /// The proxy 00124 TAO_CEC_ProxyPushSupplier* proxy_; 00125 00126 /// The event 00127 CORBA::Any event_; 00128 }; 00129 00130 // **************************************************************** 00131 00132 #if defined (TAO_HAS_TYPED_EVENT_CHANNEL) 00133 class TAO_Event_Serv_Export TAO_CEC_Invoke_Command : public TAO_CEC_Dispatch_Command 00134 { 00135 public: 00136 /// Constructor 00137 TAO_CEC_Invoke_Command (TAO_CEC_ProxyPushSupplier* proxy, 00138 TAO_CEC_TypedEvent& typed_event, 00139 ACE_Data_Block* data_block, 00140 ACE_Allocator *mb_allocator); 00141 00142 /// Destructor 00143 virtual ~TAO_CEC_Invoke_Command (void); 00144 00145 /// Command callback 00146 virtual int execute (ACE_ENV_SINGLE_ARG_DECL_NOT_USED); 00147 00148 private: 00149 /// The proxy 00150 TAO_CEC_ProxyPushSupplier* proxy_; 00151 00152 /// The event 00153 TAO_CEC_TypedEvent typed_event_; 00154 }; 00155 #endif /* TAO_HAS_TYPED_EVENT_CHANNEL */ 00156 00157 TAO_END_VERSIONED_NAMESPACE_DECL 00158 00159 #if defined (__ACE_INLINE__) 00160 #include "orbsvcs/CosEvent/CEC_Dispatching_Task.i" 00161 #endif /* __ACE_INLINE__ */ 00162 00163 #include /**/ "ace/post.h" 00164 00165 #endif /* TAO_CEC_DISPATCHING_TASK_H */