diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-11-19 16:27:37 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-11-19 16:27:37 +0000 |
commit | ad4ff7915bbd9ce15435bf9960893f9a6768dab6 (patch) | |
tree | ad80346889d15e802567e2954619e9b23e389b10 /TAO/orbsvcs/orbsvcs/Event | |
parent | bd37552834074ea5a26387a08d1942ad8d6f8e67 (diff) | |
download | ATCD-ad4ff7915bbd9ce15435bf9960893f9a6768dab6.tar.gz |
ChangeLogTag:Thu Nov 19 10:15:28 1998 Carlos O'Ryan <coryan@cs.wustl.edu>
Diffstat (limited to 'TAO/orbsvcs/orbsvcs/Event')
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Event/Event_Channel.cpp | 54 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Event/Event_Channel.h | 52 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Event/Event_Channel.i | 30 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Event/Module_Factory.h | 2 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Event/Timer_Module.cpp | 99 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Event/Timer_Module.h | 44 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Event/Timer_Module.i | 6 |
7 files changed, 161 insertions, 126 deletions
diff --git a/TAO/orbsvcs/orbsvcs/Event/Event_Channel.cpp b/TAO/orbsvcs/orbsvcs/Event/Event_Channel.cpp index c7f00203376..20ebb969b38 100644 --- a/TAO/orbsvcs/orbsvcs/Event/Event_Channel.cpp +++ b/TAO/orbsvcs/orbsvcs/Event/Event_Channel.cpp @@ -20,10 +20,10 @@ #include "Event_Channel.i" #endif /* __ACE_INLINE__ */ -#include "tao/Timeprobe.h" - ACE_RCSID(Event, Event_Channel, "$Id$") +#include "tao/Timeprobe.h" + #if defined (ACE_ENABLE_TIMEPROBES) static const char *TAO_Event_Channel_Timeprobe_Description[] = @@ -45,8 +45,6 @@ static const char *TAO_Event_Channel_Timeprobe_Description[] = "end push_source_type", "deliver to Supplier Module (thru Supplier Proxy)", "connected - priority requested", - "ES_Priority_Queue - start execute", - "ES_Priority_Queue - end execute", "Consumer_Name - priority requested", "Consumer_Name - priority obtained", "deliver event to consumer proxy", @@ -74,8 +72,6 @@ enum TAO_EVENT_CHANNEL_END_PUSH_SOURCE_TYPE, TAO_EVENT_CHANNEL_DELIVER_TO_SUPPLIER_MODULE_THRU_SUPPLIER_PROXY, TAO_EVENT_CHANNEL_CONNECTED_PRIORITY_REQUESTED, - TAO_EVENT_CHANNEL_ES_PRIORITY_QUEUE_START_EXECUTE, - TAO_EVENT_CHANNEL_ES_PRIORITY_QUEUE_END_EXECUTE, TAO_EVENT_CHANNEL_CONSUMER_NAME_PRIORITY_REQUESTED, TAO_EVENT_CHANNEL_CONSUMER_NAME_PRIORITY_OBTAINED, TAO_EVENT_CHANNEL_DELIVER_EVENT_TO_CONSUMER_PROXY, @@ -229,7 +225,7 @@ public: // ************************************************************ -class TAO_ORBSVCS_Export Flush_Queue_ACT : public ACE_ES_Timer_ACT +class TAO_ORBSVCS_Export Flush_Queue_ACT : public ACE_Command_Base // = TITLE // Flush Queue Asynchronous Completion Token // @@ -243,7 +239,7 @@ public: request_ (request), dispatching_module_ (dispatching_module) { } - virtual void execute (void) + virtual int execute (void* arg = 0) { TAO_TRY { @@ -258,6 +254,7 @@ public: "Unknown exception..\n")); } TAO_ENDTRY; + return 0; } ACE_ES_Dispatch_Request *request_; @@ -1511,7 +1508,7 @@ int ACE_ES_Correlation_Module::cancel_timeout (ACE_ES_Consumer_Rep_Timeout *consumer) { // Cancel the timer from the Priority Timer. - ACE_ES_Timer_ACT *act; + ACE_Command_Base *act; this->channel_->cancel_timer (consumer->preemption_priority (), consumer->timer_id (), act); @@ -2112,16 +2109,17 @@ ACE_ES_Consumer_Rep::~ACE_ES_Consumer_Rep (void) { } -void -ACE_ES_Consumer_Rep::execute (void) +int +ACE_ES_Consumer_Rep::execute (void* arg) { ACE_ERROR ((LM_ERROR, "Warning! ACE_ES_Consumer_Rep::execute called.\n")); + return -1; } // ************************************************************ -void -ACE_ES_Consumer_Rep_Timeout::execute (void) +int +ACE_ES_Consumer_Rep_Timeout::execute (void* arg) { ACE_TIMEPROBE (TAO_EVENT_CHANNEL_CONSUMER_REP_TIMEOUT_EXECUTE); if (this->receiving_events ()) @@ -2133,8 +2131,11 @@ ACE_ES_Consumer_Rep_Timeout::execute (void) this->timeout_event_, __env); if (__env.exception () != 0) - ACE_ERROR ((LM_ERROR, "ACE_ES_Consumer_Rep_Timeout::execute: unexpected exception.\n")); + ACE_ERROR_RETURN ((LM_ERROR, + "ACE_ES_Consumer_Rep_Timeout::execute: " + "unexpected exception.\n"), -1); } + return 0; } // ************************************************************ @@ -3237,31 +3238,6 @@ ACE_ES_Supplier_Module::fill_qos (RtecEventChannelAdmin::SupplierQOS& s_qos) // ************************************************************ -TAO_EC_Timeout_Handler::TAO_EC_Timeout_Handler (void) -{ -} - -int -TAO_EC_Timeout_Handler::handle_timeout (const ACE_Time_Value &, - const void *vp) -{ - ACE_ES_Timer_ACT *act = (ACE_ES_Timer_ACT *) vp; - - if (act == 0) - ACE_ERROR_RETURN ((LM_ERROR, "ACE_ES_Priority_Timer::handle_timeout: " - "received act == 0!!!.\n"), 0); - - { - ACE_FUNCTION_TIMEPROBE (TAO_EVENT_CHANNEL_ES_PRIORITY_QUEUE_START_EXECUTE); - - act->execute (); - } - - return 0; -} - -// ************************************************************ - const char * ACE_ES_Consumer_Name (const RtecEventChannelAdmin::ConsumerQOS &qos, CORBA::Environment &_env) diff --git a/TAO/orbsvcs/orbsvcs/Event/Event_Channel.h b/TAO/orbsvcs/orbsvcs/Event/Event_Channel.h index 27ed245a42d..4a1b1302219 100644 --- a/TAO/orbsvcs/orbsvcs/Event/Event_Channel.h +++ b/TAO/orbsvcs/orbsvcs/Event/Event_Channel.h @@ -37,6 +37,7 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/Map_Manager.h" +#include "ace/Functor.h" #include "tao/Timeprobe.h" #include "orbsvcs/Scheduler_Factory.h" @@ -147,30 +148,6 @@ private: // ************************************************************ -class ACE_ES_Timer_ACT; -class ACE_EventChannel; - -class TAO_ORBSVCS_Export TAO_EC_Timeout_Handler : public ACE_Event_Handler -{ - // = TITLE - // Event Service Timeout handler. - // - // = DESCRIPTION - // Receives the timeouts from the Timer_Module and dispatches them - // as Event Channel events. - // -public: - TAO_EC_Timeout_Handler (void); - // Default construction. - -private: - virtual int handle_timeout (const ACE_Time_Value &tv, - const void *act); - // Casts <act> to ACE_ES_Timer_ACT and calls execute. -}; - -// ************************************************************ - // Chesire cat. class ACE_ES_Priority_Timer; // Forward declarations. @@ -228,8 +205,6 @@ public: ACE_ES_Subscription_Module *subscription_module_; ACE_ES_Supplier_Module *supplier_module_; - TAO_EC_Timeout_Handler timer_; - void report_connect (u_long); // Consumer or supplier connected. @@ -284,7 +259,7 @@ public: // = Timer managment int schedule_timer (RtecScheduler::handle_t rt_info, - const ACE_ES_Timer_ACT *act, + const ACE_Command_Base *act, RtecScheduler::OS_Priority preemption_priority, const RtecScheduler::Time& delta, const RtecScheduler::Time& interval = ORBSVCS_Time::zero); @@ -293,7 +268,7 @@ public: int cancel_timer (RtecScheduler::OS_Priority preemption_priority, int id, - ACE_ES_Timer_ACT *&act); + ACE_Command_Base *&act); // Cancel the timer associated with the priority of // <preemption_priority> and <id>. <act> is filled in with the // Timer_ACT used when scheduling the timer. Returns 0 on success, @@ -432,19 +407,6 @@ protected: }; // ************************************************************ - -class TAO_ORBSVCS_Export ACE_ES_Timer_ACT -// = TITLE -// Timer Asynchronous Completion Token -// -// = DESCRIPTION -// Implements Command pattern with timers. -{ -public: - virtual void execute (void) = 0; -}; - -// ************************************************************ // Forward decl. class ACE_ES_Consumer_Rep_Timeout; @@ -533,7 +495,7 @@ private: // Forward decl. class ACE_ES_Consumer_Correlation; -class TAO_ORBSVCS_Export ACE_ES_Consumer_Rep : public ACE_ES_Timer_ACT +class TAO_ORBSVCS_Export ACE_ES_Consumer_Rep : public ACE_Command_Base // = TITLE // Consumer Representation. // @@ -541,7 +503,7 @@ class TAO_ORBSVCS_Export ACE_ES_Consumer_Rep : public ACE_ES_Timer_ACT // These are stored in the subscription module. They store // information that allows optimized correlations. It represents // the consumer that will handle *one* type of event. This -// probably shouldn't inherit from ACE_ES_Timer_ACT since it's used +// probably shouldn't inherit from ACE_Command_Base since it's used // only by ACE_ES_Consumer_Rep_Timeout. However, this allows me to // minimize dynamic allocation. { @@ -627,7 +589,7 @@ protected: int disconnected_; // Whether the rep should be removed from all subscription lists. - virtual void execute (void); + virtual int execute (void* arg = 0); // This is called when timeouts occur. This implementation prints // out an error message (since it really shouldn't be implemented in // this class). @@ -681,7 +643,7 @@ public: void preemption_priority (RtecScheduler::OS_Priority pp); protected: - virtual void execute (void); + virtual int execute (void* arg = 0); // This is called when timeouts occur. Calls correlation_-> int timer_id_; diff --git a/TAO/orbsvcs/orbsvcs/Event/Event_Channel.i b/TAO/orbsvcs/orbsvcs/Event/Event_Channel.i index 805fddb9087..710add82135 100644 --- a/TAO/orbsvcs/orbsvcs/Event/Event_Channel.i +++ b/TAO/orbsvcs/orbsvcs/Event/Event_Channel.i @@ -685,7 +685,7 @@ ACE_ES_Conjunction_Group::add_events (TAO_EC_Event_Array *outbox, ACE_INLINE int ACE_EventChannel::schedule_timer (RtecScheduler::handle_t rt_info, - const ACE_ES_Timer_ACT *act, + const ACE_Command_Base *act, RtecScheduler::Preemption_Priority_t preemption_priority, const RtecScheduler::Time &delta, const RtecScheduler::Time &interval) @@ -721,33 +721,19 @@ ACE_EventChannel::schedule_timer (RtecScheduler::handle_t rt_info, ORBSVCS_Time::TimeT_to_Time_Value (tv_interval, interval); return this->timer_module ()->schedule_timer (preemption_priority, - &this->timer_, - ACE_const_cast(ACE_ES_Timer_ACT*,act), - tv_delta, tv_interval); + ACE_const_cast(ACE_Command_Base*,act), + tv_delta, + tv_interval); } ACE_INLINE int ACE_EventChannel::cancel_timer (RtecScheduler::OS_Priority preemption_priority, int id, - ACE_ES_Timer_ACT *&act) + ACE_Command_Base *&act) { - const void *vp; - - int result = - this->timer_module ()->cancel_timer (preemption_priority, - id, - vp); - - if (result == 0) - { - ACE_ERROR ((LM_ERROR, "ACE_ES_Priority_Timer::cancel_timer: " - "Tried to cancel nonexistent timer.\n")); - act = 0; - } - else - act = (ACE_ES_Timer_ACT *) vp; - - return result; + return this->timer_module ()->cancel_timer (preemption_priority, + id, + act); } // ************************************************************ diff --git a/TAO/orbsvcs/orbsvcs/Event/Module_Factory.h b/TAO/orbsvcs/orbsvcs/Event/Module_Factory.h index 8233726cdea..d7fa4abf2b4 100644 --- a/TAO/orbsvcs/orbsvcs/Event/Module_Factory.h +++ b/TAO/orbsvcs/orbsvcs/Event/Module_Factory.h @@ -35,7 +35,7 @@ class ACE_ES_Dispatching_Base; class ACE_ES_Consumer_Module; class ACE_ES_Correlation_Module; class ACE_ES_Subscription_Module; -class ACE_ES_Supplier_Modulel; +class ACE_ES_Supplier_Module; class ACE_ES_Priority_Timer; class TAO_EC_Timer_Module; diff --git a/TAO/orbsvcs/orbsvcs/Event/Timer_Module.cpp b/TAO/orbsvcs/orbsvcs/Event/Timer_Module.cpp index 4e0e8fe501d..70a0abf443b 100644 --- a/TAO/orbsvcs/orbsvcs/Event/Timer_Module.cpp +++ b/TAO/orbsvcs/orbsvcs/Event/Timer_Module.cpp @@ -1,5 +1,7 @@ // $Id$ +#include "ace/Functor.h" + #include "orbsvcs/orbsvcs/Event/ReactorTask.h" #include "orbsvcs/orbsvcs/Event/Timer_Module.h" @@ -9,6 +11,28 @@ ACE_RCSID(Event, Timer_Module, "$Id$") +#include "tao/Timeprobe.h" + +#if defined (ACE_ENABLE_TIMEPROBES) +static const char *TAO_Timer_Module_Timeprobe_Description[] = +{ + "Timer_Module - start execute", + "Timer_Module - end execute" +}; + +enum +{ + // Timeprobe description table start key + TAO_EC_TIMER_MODULE_START_EXECUTE = 5400, + TAO_EC_TIMER_MOUDLE_END_EXECUTE +}; + +// Setup Timeprobes +ACE_TIMEPROBE_EVENT_DESCRIPTIONS (TAO_Timer_Module_Timeprobe_Description, + TAO_EC_TIMER_MODULE_START_EXECUTE); + +#endif /* ACE_ENABLE_TIMEPROBES */ + // **************************************************************** TAO_EC_Timer_Module::~TAO_EC_Timer_Module (void) @@ -34,6 +58,7 @@ TAO_EC_ST_Timer_Module::activate (void) void TAO_EC_ST_Timer_Module::shutdown (void) { + this->reactor_->cancel_timer (&this->timeout_handler_); } RtecScheduler::handle_t @@ -45,20 +70,34 @@ TAO_EC_ST_Timer_Module::rt_info (RtecScheduler::Preemption_Priority_t) int TAO_EC_ST_Timer_Module::schedule_timer (RtecScheduler::Preemption_Priority_t, - ACE_Event_Handler* eh, - void* act, + ACE_Command_Base* act, const ACE_Time_Value& delta, const ACE_Time_Value& interval) { - return this->reactor_->schedule_timer (eh, act, delta, interval); + return this->reactor_->schedule_timer (&this->timeout_handler_, + ACE_static_cast(void*,act), + delta, interval); } int TAO_EC_ST_Timer_Module::cancel_timer (RtecScheduler::Preemption_Priority_t, int id, - const void*& act) + ACE_Command_Base*& act) { - return this->reactor_->cancel_timer (id, &act); + const void *vp; + + int result = + this->reactor_->cancel_timer (id, &vp); + if (result == 0) + { + ACE_ERROR ((LM_ERROR, "TAO_EC_ST_Timer_Module::cancel_timer: " + "Tried to cancel nonexistent timer.\n")); + act = 0; + } + else + act = ACE_static_cast (ACE_Command_Base *, vp); + + return result; } int @@ -138,6 +177,7 @@ TAO_EC_RPT_Timer_Module::shutdown (void) { if (this->reactorTasks[i] != 0) this->reactorTasks[i]->shutdown_task (); + this->reactorTasks[i]->get_reactor ().cancel_timer (&this->timeout_handler_); } if (this->ThrMgr ()->wait () == -1) @@ -152,20 +192,36 @@ TAO_EC_RPT_Timer_Module::rt_info (RtecScheduler::Preemption_Priority_t priority) int TAO_EC_RPT_Timer_Module::schedule_timer (RtecScheduler::Preemption_Priority_t priority, - ACE_Event_Handler* eh, - void* act, + ACE_Command_Base* act, const ACE_Time_Value& delta, const ACE_Time_Value& interval) { - return this->GetReactorTask (priority)->get_reactor ().schedule_timer (eh, act, delta, interval); + ACE_Reactor& reactor = this->GetReactorTask (priority)->get_reactor (); + return reactor.schedule_timer (&this->timeout_handler_, + ACE_static_cast(void*,act), + delta, interval); } int TAO_EC_RPT_Timer_Module::cancel_timer (RtecScheduler::Preemption_Priority_t priority, int id, - const void*& act) + ACE_Command_Base*& act) { - return this->GetReactorTask (priority)->get_reactor ().cancel_timer (id, &act); + const void* vp; + ACE_Reactor& reactor = this->GetReactorTask (priority)->get_reactor (); + + int result = + reactor.cancel_timer (id, &vp); + if (result == 0) + { + ACE_ERROR ((LM_ERROR, "TAO_EC_ST_Timer_Module::cancel_timer: " + "Tried to cancel nonexistent timer.\n")); + act = 0; + } + else + act = ACE_static_cast (ACE_Command_Base *, vp); + + return result; } int @@ -181,3 +237,26 @@ TAO_EC_RPT_Timer_Module::reactor (RtecScheduler::Preemption_Priority_t priority) { return &this->GetReactorTask (priority)->get_reactor (); } + +// **************************************************************** + +int +TAO_EC_Timeout_Handler::handle_timeout (const ACE_Time_Value &, + const void *vp) +{ + ACE_Command_Base *act = ACE_static_cast(ACE_Command_Base*, + ACE_const_cast(void*,vp)); + + if (act == 0) + ACE_ERROR_RETURN ((LM_ERROR, "ACE_ES_Priority_Timer::handle_timeout: " + "received act == 0!!!.\n"), 0); + + { + ACE_FUNCTION_TIMEPROBE (TAO_EVENT_CHANNEL_ES_PRIORITY_QUEUE_START_EXECUTE); + + act->execute (); + } + + return 0; +} + diff --git a/TAO/orbsvcs/orbsvcs/Event/Timer_Module.h b/TAO/orbsvcs/orbsvcs/Event/Timer_Module.h index dc683fe69e3..0f22e10b8cd 100644 --- a/TAO/orbsvcs/orbsvcs/Event/Timer_Module.h +++ b/TAO/orbsvcs/orbsvcs/Event/Timer_Module.h @@ -15,6 +15,8 @@ #include "orbsvcs/Event_Service_Constants.h" #include "orbsvcs/orbsvcs/Event/RT_Task.h" +class ACE_Command_Base; + class TAO_ORBSVCS_Export TAO_EC_Timer_Module { // = TITLE @@ -46,15 +48,14 @@ public: // The RT_Info handle for the "task" at <priority> virtual int schedule_timer (RtecScheduler::Preemption_Priority_t priority, - ACE_Event_Handler* eh, - void* act, + ACE_Command_Base* act, const ACE_Time_Value& delta, const ACE_Time_Value& interval) = 0; // Add a timer at the given priority, returns the timer ID. virtual int cancel_timer (RtecScheduler::Preemption_Priority_t priority, int id, - const void*& act) = 0; + ACE_Command_Base*& act) = 0; // Add a timer at the given priority. virtual int register_handler (RtecScheduler::Preemption_Priority_t priority, @@ -70,6 +71,27 @@ public: // **************************************************************** +class TAO_ORBSVCS_Export TAO_EC_Timeout_Handler : public ACE_Event_Handler +{ + // = TITLE + // Event Service Timeout handler. + // + // = DESCRIPTION + // This is used by the Timer_Modules as an adaptor between the + // reactor (Event_Handler) and the Command objects. + // +public: + TAO_EC_Timeout_Handler (void); + // Default construction. + +private: + virtual int handle_timeout (const ACE_Time_Value &tv, + const void *act); + // Casts <act> to ACE_Command_Base and calls execute. +}; + +// **************************************************************** + class TAO_ORBSVCS_Export TAO_EC_ST_Timer_Module : public TAO_EC_Timer_Module { // = TITLE @@ -92,13 +114,12 @@ public: virtual RtecScheduler::handle_t rt_info (RtecScheduler::Preemption_Priority_t priority); virtual int schedule_timer (RtecScheduler::Preemption_Priority_t priority, - ACE_Event_Handler* eh, - void* act, + ACE_Command_Base* act, const ACE_Time_Value& delta, const ACE_Time_Value& interval); virtual int cancel_timer (RtecScheduler::Preemption_Priority_t priority, int id, - const void*& act); + ACE_Command_Base*& act); virtual int register_handler (RtecScheduler::Preemption_Priority_t priority, ACE_Event_Handler* eh, ACE_HANDLE handle); @@ -107,6 +128,9 @@ public: private: ACE_Reactor* reactor_; // The reactor. + + TAO_EC_Timeout_Handler timeout_handler_; + // To receive the timeouts. }; // **************************************************************** @@ -146,13 +170,12 @@ public: virtual RtecScheduler::handle_t rt_info (RtecScheduler::Preemption_Priority_t priority); virtual int schedule_timer (RtecScheduler::Preemption_Priority_t priority, - ACE_Event_Handler* eh, - void* act, + ACE_Command_Base* act, const ACE_Time_Value& delta, const ACE_Time_Value& interval); virtual int cancel_timer (RtecScheduler::Preemption_Priority_t priority, int id, - const void*& act); + ACE_Command_Base*& act); virtual int register_handler (RtecScheduler::Preemption_Priority_t priority, ACE_Event_Handler* eh, ACE_HANDLE handle); @@ -167,6 +190,9 @@ private: ACE_RT_Thread_Manager thr_mgr; // The thread manager. + + TAO_EC_Timeout_Handler timeout_handler_; + // To receive the timeouts. }; #if defined (__ACE_INLINE__) diff --git a/TAO/orbsvcs/orbsvcs/Event/Timer_Module.i b/TAO/orbsvcs/orbsvcs/Event/Timer_Module.i index 5451e776399..0ea11e7dbc0 100644 --- a/TAO/orbsvcs/orbsvcs/Event/Timer_Module.i +++ b/TAO/orbsvcs/orbsvcs/Event/Timer_Module.i @@ -23,4 +23,10 @@ TAO_EC_RPT_Timer_Module::ThrMgr() return &thr_mgr; } +// **************************************************************** + +ACE_INLINE +TAO_EC_Timeout_Handler::TAO_EC_Timeout_Handler (void) +{ +} |