EC_Dispatching_Task.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 /**
00004  *  @file   EC_Dispatching_Task.h
00005  *
00006  *  EC_Dispatching_Task.h,v 1.24 2006/03/15 07:52:21 jtc Exp
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_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 /* ACE_LACKS_PRAGMA_ONCE */
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 // Forward decl
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   // Called when
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
00054                                  ACE_ENV_ARG_DECL) = 0;
00055 };
00056 
00057 class TAO_RTEvent_Serv_Export TAO_EC_Simple_Queue_Full_Action :
00058   public TAO_EC_Queue_Full_Service_Object
00059 {
00060 public:
00061   TAO_EC_Simple_Queue_Full_Action ();
00062 
00063   /// Helper function to register the default action into the service
00064   /// configurator.
00065   static int init_svcs (void);
00066 
00067   // = The Service_Object entry points
00068   virtual int init (int argc, char* argv[]);
00069   virtual int fini (void);
00070 
00071   virtual int queue_full_action (TAO_EC_Dispatching_Task *task,
00072                                  TAO_EC_ProxyPushSupplier *proxy,
00073                                  RtecEventComm::PushConsumer_ptr consumer,
00074                                  RtecEventComm::EventSet& event
00075                                  ACE_ENV_ARG_DECL);
00076 
00077 protected:
00078   int queue_full_action_return_value_;
00079 };
00080 
00081 class TAO_RTEvent_Serv_Export TAO_EC_Queue : public ACE_Message_Queue<ACE_SYNCH>
00082 {
00083 public:
00084   TAO_EC_Queue (size_t high_water_mark = ACE_Message_Queue_Base::DEFAULT_HWM,
00085                 size_t low_water_mark = ACE_Message_Queue_Base::DEFAULT_LWM,
00086                 ACE_Notification_Strategy * = 0);
00087 
00088 protected:
00089   // = Override the default definition in the Message_Queue, to count
00090   // the number of messages (and not their size).
00091   virtual int is_full_i (void);
00092 };
00093 
00094 /**
00095  * @class TAO_EC_Dispatching_Task
00096  *
00097  * @brief Implement the dispatching queues for FIFO and Priority
00098  * dispatching.
00099  *
00100  */
00101 class TAO_RTEvent_Serv_Export TAO_EC_Dispatching_Task : public ACE_Task<ACE_SYNCH>
00102 {
00103 public:
00104   /// Constructor
00105   TAO_EC_Dispatching_Task (ACE_Thread_Manager* thr_manager = 0, TAO_EC_Queue_Full_Service_Object* queue_full_service_object = 0);
00106 
00107   /// Process the events in the queue.
00108   virtual int svc (void);
00109 
00110   virtual void push (TAO_EC_ProxyPushSupplier *proxy,
00111                      RtecEventComm::PushConsumer_ptr consumer,
00112                      RtecEventComm::EventSet& event
00113                      ACE_ENV_ARG_DECL);
00114 
00115 private:
00116   /// An per-task allocator
00117   ACE_Allocator *allocator_;
00118 
00119   /// Helper data structure to minimize memory allocations...
00120   ACE_Locked_Data_Block<ACE_Lock_Adapter<TAO_SYNCH_MUTEX> > data_block_;
00121 
00122   /// The queue
00123   TAO_EC_Queue the_queue_;
00124 
00125   TAO_EC_Queue_Full_Service_Object* queue_full_service_object_;
00126 };
00127 
00128 // ****************************************************************
00129 
00130 class TAO_RTEvent_Serv_Export TAO_EC_Dispatch_Command : public ACE_Message_Block
00131 {
00132 public:
00133   /// Constructor, it will allocate its own data block
00134   TAO_EC_Dispatch_Command (ACE_Allocator *mb_allocator = 0);
00135 
00136   /// Constructor, it assumes ownership of the data block
00137   TAO_EC_Dispatch_Command (ACE_Data_Block*,
00138                            ACE_Allocator *mb_allocator = 0);
00139 
00140   /// Destructor
00141   virtual ~TAO_EC_Dispatch_Command (void);
00142 
00143   /// Command callback
00144   virtual int execute (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) = 0;
00145 };
00146 
00147 // ****************************************************************
00148 
00149 class TAO_RTEvent_Serv_Export TAO_EC_Shutdown_Task_Command : public TAO_EC_Dispatch_Command
00150 {
00151 public:
00152   /// Constructor
00153   TAO_EC_Shutdown_Task_Command (ACE_Allocator *mb_allocator = 0);
00154 
00155   /// Command callback
00156   virtual int execute (ACE_ENV_SINGLE_ARG_DECL_NOT_USED);
00157 };
00158 
00159 // ****************************************************************
00160 
00161 class TAO_RTEvent_Serv_Export TAO_EC_Push_Command : public TAO_EC_Dispatch_Command
00162 {
00163 public:
00164   /// Constructor
00165   TAO_EC_Push_Command (TAO_EC_ProxyPushSupplier* proxy,
00166                        RtecEventComm::PushConsumer_ptr consumer,
00167                        RtecEventComm::EventSet& event,
00168                        ACE_Data_Block* data_block,
00169                        ACE_Allocator *mb_allocator);
00170 
00171   /// Destructor
00172   virtual ~TAO_EC_Push_Command (void);
00173 
00174   /// Command callback
00175   virtual int execute (ACE_ENV_SINGLE_ARG_DECL_NOT_USED);
00176 
00177 private:
00178   /// The proxy
00179   TAO_EC_ProxyPushSupplier* proxy_;
00180 
00181   /// The consumer connected to the proxy when the event was pushed.
00182   RtecEventComm::PushConsumer_var consumer_;
00183 
00184   /// The event
00185   RtecEventComm::EventSet event_;
00186 };
00187 
00188 TAO_END_VERSIONED_NAMESPACE_DECL
00189 
00190 #if defined (__ACE_INLINE__)
00191 #include "orbsvcs/Event/EC_Dispatching_Task.i"
00192 #endif /* __ACE_INLINE__ */
00193 
00194 ACE_STATIC_SVC_DECLARE (TAO_EC_Simple_Queue_Full_Action)
00195 ACE_FACTORY_DECLARE (TAO_RTEvent_Serv, TAO_EC_Simple_Queue_Full_Action)
00196 
00197 #include /**/ "ace/post.h"
00198 
00199 #endif  /* TAO_EC_DISPATCHING_TASK_H */

Generated on Thu Nov 9 13:11:07 2006 for TAO_RTEvent by doxygen 1.3.6