00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef TAO_EC_DISPATCHING_TASK_H
00017 #define TAO_EC_DISPATCHING_TASK_H
00018
00019 #include "ace/pre.h"
00020
00021 #include "orbsvcs/Event/EC_ProxySupplier.h"
00022
00023 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00024 # pragma once
00025 #endif
00026
00027 #include "orbsvcs/RtecEventCommC.h"
00028 #include "orbsvcs/Event/event_serv_export.h"
00029 #include "ace/Task.h"
00030 #include "ace/Message_Block.h"
00031 #include "ace/Lock_Adapter_T.h"
00032 #include "ace/Service_Config.h"
00033 #include "ace/Global_Macros.h"
00034
00035 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00036
00037
00038 class TAO_EC_Dispatching_Task;
00039
00040 class TAO_RTEvent_Serv_Export TAO_EC_Queue_Full_Service_Object : public ACE_Service_Object
00041 {
00042 public:
00043 enum QueueFullActionReturnValue
00044 {
00045 WAIT_TO_EMPTY = 0,
00046 SILENTLY_DISCARD = -1
00047 };
00048
00049
00050 virtual int queue_full_action (TAO_EC_Dispatching_Task *task,
00051 TAO_EC_ProxyPushSupplier *proxy,
00052 RtecEventComm::PushConsumer_ptr consumer,
00053 RtecEventComm::EventSet& event) = 0;
00054 };
00055
00056 class TAO_RTEvent_Serv_Export TAO_EC_Simple_Queue_Full_Action :
00057 public TAO_EC_Queue_Full_Service_Object
00058 {
00059 public:
00060 TAO_EC_Simple_Queue_Full_Action ();
00061
00062
00063
00064 static int init_svcs (void);
00065
00066
00067 virtual int init (int argc, char* argv[]);
00068 virtual int fini (void);
00069
00070 virtual int queue_full_action (TAO_EC_Dispatching_Task *task,
00071 TAO_EC_ProxyPushSupplier *proxy,
00072 RtecEventComm::PushConsumer_ptr consumer,
00073 RtecEventComm::EventSet& event);
00074
00075 protected:
00076 int queue_full_action_return_value_;
00077 };
00078
00079 class TAO_RTEvent_Serv_Export TAO_EC_Queue : public ACE_Message_Queue<ACE_SYNCH>
00080 {
00081 public:
00082 TAO_EC_Queue (size_t high_water_mark = ACE_Message_Queue_Base::DEFAULT_HWM,
00083 size_t low_water_mark = ACE_Message_Queue_Base::DEFAULT_LWM,
00084 ACE_Notification_Strategy * = 0);
00085
00086 protected:
00087
00088
00089 virtual bool is_full_i (void);
00090 };
00091
00092
00093
00094
00095
00096
00097
00098
00099 class TAO_RTEvent_Serv_Export TAO_EC_Dispatching_Task : public ACE_Task<ACE_SYNCH>
00100 {
00101 public:
00102
00103 TAO_EC_Dispatching_Task (ACE_Thread_Manager* thr_manager = 0, TAO_EC_Queue_Full_Service_Object* queue_full_service_object = 0);
00104
00105
00106 virtual int svc (void);
00107
00108 virtual void push (TAO_EC_ProxyPushSupplier *proxy,
00109 RtecEventComm::PushConsumer_ptr consumer,
00110 RtecEventComm::EventSet& event);
00111
00112 private:
00113
00114 ACE_Allocator *allocator_;
00115
00116
00117 ACE_Locked_Data_Block<ACE_Lock_Adapter<TAO_SYNCH_MUTEX> > data_block_;
00118
00119
00120 TAO_EC_Queue the_queue_;
00121
00122 TAO_EC_Queue_Full_Service_Object* queue_full_service_object_;
00123 };
00124
00125
00126
00127 class TAO_RTEvent_Serv_Export TAO_EC_Dispatch_Command : public ACE_Message_Block
00128 {
00129 public:
00130
00131 TAO_EC_Dispatch_Command (ACE_Allocator *mb_allocator = 0);
00132
00133
00134 TAO_EC_Dispatch_Command (ACE_Data_Block*,
00135 ACE_Allocator *mb_allocator = 0);
00136
00137
00138 virtual ~TAO_EC_Dispatch_Command (void);
00139
00140
00141 virtual int execute (void) = 0;
00142 };
00143
00144
00145
00146 class TAO_RTEvent_Serv_Export TAO_EC_Shutdown_Task_Command : public TAO_EC_Dispatch_Command
00147 {
00148 public:
00149
00150 TAO_EC_Shutdown_Task_Command (ACE_Allocator *mb_allocator = 0);
00151
00152
00153 virtual int execute (void);
00154 };
00155
00156
00157
00158 class TAO_RTEvent_Serv_Export TAO_EC_Push_Command : public TAO_EC_Dispatch_Command
00159 {
00160 public:
00161
00162 TAO_EC_Push_Command (TAO_EC_ProxyPushSupplier* proxy,
00163 RtecEventComm::PushConsumer_ptr consumer,
00164 RtecEventComm::EventSet& event,
00165 ACE_Data_Block* data_block,
00166 ACE_Allocator *mb_allocator);
00167
00168
00169 virtual ~TAO_EC_Push_Command (void);
00170
00171
00172 virtual int execute (void);
00173
00174 private:
00175
00176 TAO_EC_ProxyPushSupplier* proxy_;
00177
00178
00179 RtecEventComm::PushConsumer_var consumer_;
00180
00181
00182 RtecEventComm::EventSet event_;
00183 };
00184
00185 TAO_END_VERSIONED_NAMESPACE_DECL
00186
00187 #if defined (__ACE_INLINE__)
00188 #include "orbsvcs/Event/EC_Dispatching_Task.inl"
00189 #endif
00190
00191 ACE_STATIC_SVC_DECLARE (TAO_EC_Simple_Queue_Full_Action)
00192 ACE_FACTORY_DECLARE (TAO_RTEvent_Serv, TAO_EC_Simple_Queue_Full_Action)
00193
00194 #include "ace/post.h"
00195
00196 #endif