/* -*- C++ -*- */ //============================================================================= /** * @file Dispatching_Modules.h * * $Id$ * * @author Tim Harrison (harrison@cs.wustl.edu) * * This file holds the different Event Service dispatching * mechanisms. These include null-dispatching (EFD), * single-threaded with (RTU) and without preemption (LAME), and a * multithreaded implementation. * * */ //============================================================================= #ifndef ACE_DISPATCHING_MODULES_H #define ACE_DISPATCHING_MODULES_H #include /**/ "ace/pre.h" #include "ace/Reactor_Notification_Strategy.h" #include "tao/Timeprobe.h" #include "orbsvcs/orbsvcs/Event/ReactorTask.h" #include "orbsvcs/orbsvcs/Event/Event_Manip.h" #include "orbsvcs/orbsvcs/Event/Event_Channel.h" // ************************************************************ // Forward declarations. class ACE_ES_Dispatch_Queue; class ACE_ES_Dispatch_Request; // ************************************************************ // Forward declarations. class ACE_ES_Consumer_Module; /** * @class ACE_ES_Dispatching_Base * * @brief Event Service Dispatch Module base class * * We inherit from ACE_Event_Handler so that we can be called back * by the ReactorEx when requests are queued. The virtual * dispatch_event method allows ACE_ES_Dispatch_Requests to call * back the dispatching module when acting as command objects. When * this implementation is used by the Event Channel it forwards all * dispatch calls without any queuing. Therefore, it can be * used to build an EFD. It is also inherited by the Priority * Dispatching module. */ class TAO_RTOLDEvent_Export ACE_ES_Dispatching_Base : public ACE_Event_Handler { public: /// Default construction. ACE_ES_Dispatching_Base (ACE_EventChannel *channel); /// Link to adjacent modules. virtual void open (ACE_ES_Consumer_Module *up, ACE_ES_Correlation_Module *down); /// Forward down_. virtual void connected (ACE_Push_Consumer_Proxy *consumer ACE_ENV_ARG_DECL_NOT_USED); /// Forward down_. virtual void disconnecting (ACE_Push_Consumer_Proxy *consumer ACE_ENV_ARG_DECL_NOT_USED); /// Release any unneeded dispatching resources. virtual void disconnected (ACE_Push_Consumer_Proxy *consumer); // = Not needed. // void connected (ACE_Push_Supplier_Proxy *supplier); // void disconnecting (ACE_Push_Supplier_Proxy *supplier); /// Forward up_. virtual void push (ACE_ES_Dispatch_Request *request ACE_ENV_ARG_DECL_NOT_USED) = 0; /// Called by ACE_ES_Dispatch_Requests when dequeued by RT_Tasks. virtual int dispatch_event (ACE_ES_Dispatch_Request *request, u_long &command_action); /// Called when all the threads of a have exited. virtual void dispatch_queue_closed (ACE_ES_Dispatch_Queue *q); /// This is called by the Event Channel. It will create all the /// threads and only return once they are all up and running. virtual void activate (int threads_per_queue); /// This is called by the Event Channel. This will attempt to shut /// down all of its threads gracefully. Wish it luck. virtual void shutdown (void); protected: /// Dat der channel. ACE_EventChannel *channel_; /// To synchronize thr_count_. ACE_ES_MUTEX lock_; /// The total number of threads in the Dispatching Module. This will /// be the sum of all the Dispatch Queue threads. int thr_count_; /// Next module up. ACE_ES_Consumer_Module *up_; /// Next module down. ACE_ES_Correlation_Module *down_; }; // ************************************************************ /** * @class ACE_ES_Dispatch_Request * * @brief ACE Event Service Dispatch Request * * Encapsulates a consumer and the events that will be sent to the * consumer. Right now, this class keeps a single_event_ that can * be used when only one event is sent to the consumer. Since this * is frequently the case (except for correlations), this * optimization reduces the amount of dynamic memory allocation is * necessary. This class is also a GOF Command object since it can * be dequeued by an RT_Task to call back the dispatching module * for request dispatching. */ class TAO_RTOLDEvent_Export ACE_ES_Dispatch_Request : public ACE_RT_Task_Command { public: /// Default construction. ACE_ES_Dispatch_Request (void); /// Default destruction. virtual ~ACE_ES_Dispatch_Request (void); /// All the events must be added after construction to the /// event_set. ACE_ES_Dispatch_Request (ACE_Push_Consumer_Proxy *consumer, RtecScheduler::handle_t rt_info); /// Set consumer_ to and copy to event_set_. /// describes the method receiving this dispatch. ACE_ES_Dispatch_Request (ACE_Push_Consumer_Proxy *consumer, const TAO_EC_Event_Array &event_set, RtecScheduler::handle_t rt_info); /** * Set consumer_ to and sets * single_event_.header.creation_time to