From ff969f9dd2115db477832eb4d0aaa124af1ca0d8 Mon Sep 17 00:00:00 2001 From: mcorino Date: Tue, 29 Nov 2011 15:52:02 +0000 Subject: Tue Nov 29 15:50:06 UTC 2011 Martin Corino * ace/Timer_Queue_T.h: * ace/Timer_Queue_T.inl: Added get_timer_method() to be able reuse timer method setting. * ace/Countdown_Time.h: * ace/Countdown_Time.inl: * ace/Countdown_Time.cpp: Added option to use application defined timer like timer queue. * tao/ORB_Core.cpp: * tao/params.h: * tao/params.inl: * tao/params.cpp: Added -ORBUseHighresTimer ORB parameter switch to specifiy if the ORB should use the HR timer for the reactor timer queue and related objects (like countdowns). * tao/Transport.cpp: * tao/Leader_Follower.cpp: * tao/Messaging/Messaging_Queueing_Strategies.h: * tao/Messaging/Messaging_Queueing_Strategies.cpp: Changes to support the new UseHighresTimer switch. --- ACE/ChangeLog | 15 +++++++++++++++ ACE/ace/Countdown_Time.cpp | 17 +++++++++++++---- ACE/ace/Countdown_Time.h | 16 ++++++++++++++++ ACE/ace/Countdown_Time.inl | 9 +++++++++ ACE/ace/Timer_Queue_T.h | 11 +++++++++-- ACE/ace/Timer_Queue_T.inl | 8 +++++++- TAO/ChangeLog | 18 ++++++++++++++++++ TAO/tao/Leader_Follower.cpp | 8 ++++++-- .../Messaging/Messaging_Queueing_Strategies.cpp | 11 +++++++++-- TAO/tao/Messaging/Messaging_Queueing_Strategies.h | 4 +++- TAO/tao/ORB_Core.cpp | 22 ++++++++++++++++++++++ TAO/tao/Transport.cpp | 4 +++- TAO/tao/params.cpp | 1 + TAO/tao/params.h | 7 +++++++ TAO/tao/params.inl | 11 +++++++++++ 15 files changed, 149 insertions(+), 13 deletions(-) diff --git a/ACE/ChangeLog b/ACE/ChangeLog index 8b7208370fd..f6202e9be62 100644 --- a/ACE/ChangeLog +++ b/ACE/ChangeLog @@ -1,3 +1,18 @@ +Tue Nov 29 15:50:06 UTC 2011 Martin Corino + + * ace/Timer_Queue_T.h: + * ace/Timer_Queue_T.inl: + + Added get_timer_method() to be able reuse timer method + setting. + + * ace/Countdown_Time.h: + * ace/Countdown_Time.inl: + * ace/Countdown_Time.cpp: + + Added option to use application defined timer like + timer queue. + Mon Nov 28 14:29:45 UTC 2011 Johnny Willemsen * ace/Log_Msg.h: diff --git a/ACE/ace/Countdown_Time.cpp b/ACE/ace/Countdown_Time.cpp index 335931514e4..0c7aef27029 100644 --- a/ACE/ace/Countdown_Time.cpp +++ b/ACE/ace/Countdown_Time.cpp @@ -1,7 +1,6 @@ // $Id$ #include "ace/Countdown_Time.h" -#include "ace/OS_NS_sys_time.h" #if !defined (__ACE_INLINE__) #include "ace/Countdown_Time.inl" @@ -11,7 +10,17 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_Countdown_Time::ACE_Countdown_Time (ACE_Time_Value *max_wait_time) : max_wait_time_ (max_wait_time), - stopped_ (false) + stopped_ (false), + gettimeofday_ (0) +{ + this->start (); +} + +ACE_Countdown_Time::ACE_Countdown_Time (ACE_Time_Value *max_wait_time, + ACE_Time_Value (*gettimeofday)(void)) +: max_wait_time_ (max_wait_time), + stopped_ (false), + gettimeofday_ (gettimeofday) { this->start (); } @@ -26,7 +35,7 @@ ACE_Countdown_Time::start (void) { if (this->max_wait_time_ != 0) { - this->start_time_ = ACE_OS::gettimeofday (); + this->start_time_ = this->gettimeofday (); this->stopped_ = false; } } @@ -37,7 +46,7 @@ ACE_Countdown_Time::stop (void) if (this->max_wait_time_ != 0 && !this->stopped_) { ACE_Time_Value const elapsed_time = - ACE_OS::gettimeofday () - this->start_time_; + this->gettimeofday () - this->start_time_; if (elapsed_time >= ACE_Time_Value::zero && *this->max_wait_time_ > elapsed_time) diff --git a/ACE/ace/Countdown_Time.h b/ACE/ace/Countdown_Time.h index 1d17c3aead7..cf881566299 100644 --- a/ACE/ace/Countdown_Time.h +++ b/ACE/ace/Countdown_Time.h @@ -23,6 +23,7 @@ #include "ace/Time_Value.h" #include "ace/Copy_Disabled.h" +#include "ace/OS_NS_sys_time.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -41,6 +42,11 @@ public: /// Cache the @a max_wait_time and call @c start(). ACE_Countdown_Time (ACE_Time_Value *max_wait_time); + /// Cache the @a max_wait_time and call @c start(), use + /// application supplied gettimeofday function. + ACE_Countdown_Time (ACE_Time_Value *max_wait_time, + ACE_Time_Value (*gettimeofday)(void)); + /// Destructor, makes sure the max_wait_time that got passed as pointer /// to the constructor is updated with the time elapsed. ~ACE_Countdown_Time (void); @@ -59,6 +65,13 @@ public: /// Returns true if we've already been stopped, else false. bool stopped (void) const; + /** + * Returns the current time of day. This method allows different + * instantiations of the countdown to use special high resolution + * timers. + */ + ACE_Time_Value gettimeofday (void); + private: /// Maximum time we were willing to wait. ACE_Time_Value *max_wait_time_; @@ -68,6 +81,9 @@ private: /// Keeps track of whether we've already been stopped. bool stopped_; + + /// Pointer to function that returns the current time of day. + ACE_Time_Value (*gettimeofday_)(void); }; ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Countdown_Time.inl b/ACE/ace/Countdown_Time.inl index 3911ca85bda..95a755cf291 100644 --- a/ACE/ace/Countdown_Time.inl +++ b/ACE/ace/Countdown_Time.inl @@ -17,4 +17,13 @@ ACE_Countdown_Time::update (void) this->start (); } +ACE_INLINE ACE_Time_Value +ACE_Countdown_Time::gettimeofday (void) +{ + if (this->gettimeofday_) + return this->gettimeofday_ (); + else + return ACE_OS::gettimeofday (); +} + ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Timer_Queue_T.h b/ACE/ace/Timer_Queue_T.h index 4ed6fd4a30f..1fe1e270feb 100644 --- a/ACE/ace/Timer_Queue_T.h +++ b/ACE/ace/Timer_Queue_T.h @@ -210,6 +210,9 @@ public: /// Type of Iterator. typedef ACE_Timer_Queue_Iterator_T ITERATOR; + /// Timer method type + typedef ACE_Time_Value (* TIMER_METHOD)(void); + // = Initialization and termination methods. /** * Default constructor. @a upcall_functor is the instance of the @@ -348,7 +351,11 @@ public: /// Allows applications to control how the timer queue gets the time /// of day. - void gettimeofday (ACE_Time_Value (*gettimeofday)(void)); + void gettimeofday (TIMER_METHOD gettimeofday); + + /// Allows to propagate application defined timer method to other + /// timing methods/objects. + TIMER_METHOD get_timer_method (void) const; /// Determine the next event to timeout. Returns @a max if there are /// no pending timers or if all pending timers are longer than max. @@ -443,7 +450,7 @@ protected: ACE_Free_List > *free_list_; /// Pointer to function that returns the current time of day. - ACE_Time_Value (*gettimeofday_)(void); + TIMER_METHOD gettimeofday_; /// Upcall functor FUNCTOR *upcall_functor_; diff --git a/ACE/ace/Timer_Queue_T.inl b/ACE/ace/Timer_Queue_T.inl index 7275119e2e1..30e32862618 100644 --- a/ACE/ace/Timer_Queue_T.inl +++ b/ACE/ace/Timer_Queue_T.inl @@ -208,11 +208,17 @@ ACE_Timer_Queue_T::gettimeofday (void) } template ACE_INLINE void -ACE_Timer_Queue_T::gettimeofday (ACE_Time_Value (*gettimeofday)(void)) +ACE_Timer_Queue_T::gettimeofday (TIMER_METHOD gettimeofday) { this->gettimeofday_ = gettimeofday; } +template ACE_INLINE typename ACE_Timer_Queue_T::TIMER_METHOD +ACE_Timer_Queue_T::get_timer_method (void) const +{ + return this->gettimeofday_; +} + template ACE_INLINE FUNCTOR & ACE_Timer_Queue_T::upcall_functor (void) { diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 8d230621544..a22dbec7709 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,21 @@ +Tue Nov 29 15:50:06 UTC 2011 Martin Corino + + * tao/ORB_Core.cpp: + * tao/params.h: + * tao/params.inl: + * tao/params.cpp: + + Added -ORBUseHighresTimer ORB parameter switch to specifiy + if the ORB should use the HR timer for the reactor timer queue + and related objects (like countdowns). + + * tao/Transport.cpp: + * tao/Leader_Follower.cpp: + * tao/Messaging/Messaging_Queueing_Strategies.h: + * tao/Messaging/Messaging_Queueing_Strategies.cpp: + + Changes to support the new UseHighresTimer switch. + Tue Nov 29 14:07:11 UTC 2011 Johnny Willemsen * tao/Messaging/AMH_Skeletons.h: diff --git a/TAO/tao/Leader_Follower.cpp b/TAO/tao/Leader_Follower.cpp index 427374ee726..363f804e094 100644 --- a/TAO/tao/Leader_Follower.cpp +++ b/TAO/tao/Leader_Follower.cpp @@ -3,6 +3,7 @@ #include "ace/Countdown_Time.h" #include "ace/OS_NS_sys_time.h" #include "ace/Reactor.h" +#include "ace/Timer_Queue.h" #include "ace/Auto_Ptr.h" #include "tao/Leader_Follower.h" @@ -92,7 +93,9 @@ int TAO_Leader_Follower::wait_for_client_leader_to_complete (ACE_Time_Value *max_wait_time) { int result = 0; - ACE_Countdown_Time countdown (max_wait_time); + ACE_Reactor * const reactor = this->reactor (); + ACE_Countdown_Time countdown (max_wait_time, + reactor->timer_queue ()->get_timer_method ()); // Note that we are waiting. ++this->event_loop_threads_waiting_; @@ -253,7 +256,8 @@ TAO_Leader_Follower::wait_for_event (TAO_LF_Event *event, // Obtain the lock. ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock (), -1); - ACE_Countdown_Time countdown (max_wait_time); + ACE_Countdown_Time countdown (max_wait_time, + this->reactor ()->timer_queue ()->get_timer_method ()); // Optimize the first iteration [no access to errno] int result = 1; diff --git a/TAO/tao/Messaging/Messaging_Queueing_Strategies.cpp b/TAO/tao/Messaging/Messaging_Queueing_Strategies.cpp index 90c0e441f7d..05748654ed8 100644 --- a/TAO/tao/Messaging/Messaging_Queueing_Strategies.cpp +++ b/TAO/tao/Messaging/Messaging_Queueing_Strategies.cpp @@ -3,10 +3,13 @@ #include "tao/Messaging/Messaging_Queueing_Strategies.h" #include "tao/Messaging/Buffering_Constraint_Policy.h" #include "tao/Stub.h" +#include "tao/ORB_Core.h" #include "tao/debug.h" #include "ace/Log_Msg.h" #include "ace/OS_NS_sys_time.h" +#include "ace/Reactor.h" +#include "ace/Timer_Queue.h" TAO_BEGIN_VERSIONED_NAMESPACE_DECL @@ -81,7 +84,8 @@ namespace TAO constraints_reached = true; } - if (this->timer_check (buffering_constraint, + if (this->timer_check (stub, + buffering_constraint, current_deadline, set_timer, new_deadline)) @@ -94,6 +98,7 @@ namespace TAO bool Eager_Transport_Queueing_Strategy::timer_check ( + TAO_Stub *stub, const TAO::BufferingConstraint &buffering_constraint, const ACE_Time_Value ¤t_deadline, bool &set_timer, @@ -108,7 +113,9 @@ namespace TAO } // Compute the next deadline... - ACE_Time_Value const now = ACE_OS::gettimeofday (); + ACE_Reactor * const reactor = stub->orb_core ()->reactor (); + ACE_Time_Value const now = + reactor->timer_queue ()->gettimeofday (); ACE_Time_Value timeout = this->time_conversion (buffering_constraint.timeout); new_deadline = now + timeout; diff --git a/TAO/tao/Messaging/Messaging_Queueing_Strategies.h b/TAO/tao/Messaging/Messaging_Queueing_Strategies.h index 9bceb8518a6..2bf7c425b84 100644 --- a/TAO/tao/Messaging/Messaging_Queueing_Strategies.h +++ b/TAO/tao/Messaging/Messaging_Queueing_Strategies.h @@ -62,6 +62,7 @@ namespace TAO /// Check if the buffering constraint includes any timeouts and /// compute the right timeout interval if needed. /** + * @param stub * @param buffering_constraint The constraints defined by the * application * @param current_deadline The current deadline @@ -73,7 +74,8 @@ namespace TAO * returns false then flushing may need to be delayed, use @c * set_timer and */ - bool timer_check (const TAO::BufferingConstraint &buffering_constraint, + bool timer_check (TAO_Stub *stub, + const TAO::BufferingConstraint &buffering_constraint, const ACE_Time_Value ¤t_deadline, bool &set_timer, ACE_Time_Value &new_deadline) const; diff --git a/TAO/tao/ORB_Core.cpp b/TAO/tao/ORB_Core.cpp index 774271bdfa5..dd06f2aa5a0 100644 --- a/TAO/tao/ORB_Core.cpp +++ b/TAO/tao/ORB_Core.cpp @@ -50,6 +50,8 @@ #endif /* TAO_HAS_CORBA_MESSAGING == 1 */ #include "ace/Reactor.h" +#include "ace/Timer_Queue.h" +#include "ace/High_Res_Timer.h" #include "ace/Dynamic_Service.h" #include "ace/Arg_Shifter.h" #include "ace/Argv_Type_Converter.h" @@ -779,6 +781,16 @@ TAO_ORB_Core::init (int &argc, char *argv[] ) ACE_OS::atoi (current_arg); arg_shifter.consume_arg (); } + else if (0 != (current_arg = arg_shifter.get_the_parameter + (ACE_TEXT("-ORBUseHighresTimer")))) + { + // Use Highres Timer or not (default). + int const use_highres_timer = + ACE_OS::atoi (current_arg); + this->orb_params ()->use_highres_timer (use_highres_timer != 0); + + arg_shifter.consume_arg (); + } else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-ORBAMICollocation")))) { @@ -1252,6 +1264,16 @@ TAO_ORB_Core::init (int &argc, char *argv[] ) CORBA::COMPLETED_NO); } + // handle the ORB timer setting + if (this->orb_params ()->use_highres_timer ()) + { + // intialize GSF now + (void) ACE_High_Res_Timer::global_scale_factor (); + // install highres timer for reactor timer queue + reactor->timer_queue ()->gettimeofday + (&ACE_High_Res_Timer::gettimeofday_hr); + } + TAO_Server_Strategy_Factory *ssf = this->server_factory (); if (ssf == 0) diff --git a/TAO/tao/Transport.cpp b/TAO/tao/Transport.cpp index ce7224a2287..3b5a6b6e55b 100644 --- a/TAO/tao/Transport.cpp +++ b/TAO/tao/Transport.cpp @@ -29,6 +29,7 @@ #include "ace/OS_NS_sys_time.h" #include "ace/OS_NS_stdio.h" #include "ace/Reactor.h" +#include "ace/Timer_Queue.h" #include "ace/os_include/sys/os_uio.h" #include "ace/High_Res_Timer.h" #include "ace/Countdown_Time.h" @@ -1325,7 +1326,8 @@ TAO_Transport::check_buffering_constraints_i (TAO_Stub *stub, bool &must_flush) ACE_Event_Handler *eh = this->event_handler_i (); ACE_Reactor * const reactor = eh->reactor (); this->current_deadline_ = new_deadline; - ACE_Time_Value delay = new_deadline - ACE_OS::gettimeofday (); + ACE_Time_Value delay = + new_deadline - reactor->timer_queue ()->gettimeofday (); if (this->flush_timer_pending ()) { diff --git a/TAO/tao/params.cpp b/TAO/tao/params.cpp index 4008d358ca9..4997236f46f 100644 --- a/TAO/tao/params.cpp +++ b/TAO/tao/params.cpp @@ -31,6 +31,7 @@ TAO_ORB_Parameters::TAO_ORB_Parameters (void) , linger_ (-1) , accept_error_delay_ (0) , std_profile_components_ (1) + , use_highres_timer_ (false) , ace_sched_policy_ (ACE_SCHED_OTHER) , sched_policy_ (THR_SCHED_DEFAULT) , scope_policy_ (THR_SCOPE_PROCESS) diff --git a/TAO/tao/params.h b/TAO/tao/params.h index e604e76814a..e0312f70d0d 100644 --- a/TAO/tao/params.h +++ b/TAO/tao/params.h @@ -147,6 +147,10 @@ public: bool std_profile_components (void) const; void std_profile_components (bool x); + /// Use Highres Timer for all timer events and countdowns + bool use_highres_timer (void) const; + void use_highres_timer (bool x); + /// Scheduling policy. /** * Scheduling policy specified by the user through the @@ -339,6 +343,9 @@ private: /// If true then the standard OMG components are not generated. bool std_profile_components_; + /// Use Highres timer for all timer events and countdowns + bool use_highres_timer_; + /// Scheduling policy. /** * Scheduling policy specified by the user through the diff --git a/TAO/tao/params.inl b/TAO/tao/params.inl index d148ea835e3..84f3202e3ad 100644 --- a/TAO/tao/params.inl +++ b/TAO/tao/params.inl @@ -151,6 +151,17 @@ TAO_ORB_Parameters::std_profile_components (bool x) this->std_profile_components_ = x; } +ACE_INLINE bool +TAO_ORB_Parameters::use_highres_timer (void) const +{ + return this->use_highres_timer_; +} +ACE_INLINE void +TAO_ORB_Parameters::use_highres_timer (bool x) +{ + this->use_highres_timer_ = x; +} + ACE_INLINE int TAO_ORB_Parameters::nodelay (void) const { -- cgit v1.2.1