diff options
Diffstat (limited to 'ACE')
-rw-r--r-- | ACE/ChangeLog.BRANCH | 13 | ||||
-rw-r--r-- | ACE/ace/Abstract_Timer_Queue.h | 7 | ||||
-rw-r--r-- | ACE/ace/Time_Policy.h | 24 | ||||
-rw-r--r-- | ACE/ace/Time_Policy.inl | 28 | ||||
-rw-r--r-- | ACE/ace/Time_Policy_T.h | 2 | ||||
-rw-r--r-- | ACE/ace/Time_Policy_T.inl | 5 | ||||
-rw-r--r-- | ACE/ace/Timer_Queue_T.cpp | 6 | ||||
-rw-r--r-- | ACE/ace/Timer_Queue_T.h | 10 | ||||
-rw-r--r-- | ACE/tests/Timer_Queue_Test.cpp | 2 |
9 files changed, 91 insertions, 6 deletions
diff --git a/ACE/ChangeLog.BRANCH b/ACE/ChangeLog.BRANCH index 2581e844275..adcd9f20ec5 100644 --- a/ACE/ChangeLog.BRANCH +++ b/ACE/ChangeLog.BRANCH @@ -1,3 +1,16 @@ + Mon Dec 12 21:28:00 UTC 2011 Martin Corino <mcorino@remedy.nl> + + * ace/Abstract_Timer_Queue.h: + * ace/Time_Policy.h: + * ace/Time_Policy.inl: + * ace/Time_Policy_T.h: + * ace/Time_Policy_T.inl: + * ace/Timer_Queue_T.cpp: + * ace/Timer_Queue_T.h: + * tests/Timer_Queue_Test.cpp: + + Added backwards compatibility support. + Mon Dec 05 10:26:00 UTC 2011 Martin Corino <mcorino@remedy.nl> * ace/Time_Policy.inl diff --git a/ACE/ace/Abstract_Timer_Queue.h b/ACE/ace/Abstract_Timer_Queue.h index f01817ccc7f..5164ff02972 100644 --- a/ACE/ace/Abstract_Timer_Queue.h +++ b/ACE/ace/Abstract_Timer_Queue.h @@ -161,6 +161,13 @@ public: */ virtual ACE_Time_Value gettimeofday (void) = 0; + /** + * Allows applications to control how the timer queue gets the time + * of day. + * @deprecated Use TIME_POLICY support instead. See Timer_Queue_T.h + */ + virtual void gettimeofday (ACE_Time_Value (*gettimeofday)(void)) = 0; + /// Determine the next event to timeout. Returns @a max if there are /// no pending timers or if all pending timers are longer than max. /// This method acquires a lock internally since it modifies internal state. diff --git a/ACE/ace/Time_Policy.h b/ACE/ace/Time_Policy.h index 0d8858f4009..b8f972a80e1 100644 --- a/ACE/ace/Time_Policy.h +++ b/ACE/ace/Time_Policy.h @@ -22,19 +22,22 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL /** - * @class ACE_Default_Time_Policy + * @class ACE_System_Time_Policy * - * @brief Implement the default time policy for ACE. + * @brief Implement the system time policy for ACE. * * The most common time policy is to simply use * ACE_OS::gettimeofday(), this class implements that policy, i.e., it * simply calls that function. */ -class ACE_Export ACE_Default_Time_Policy +class ACE_Export ACE_System_Time_Policy { public: /// Return the current time according to this policy ACE_Time_Value operator() () const; + + /// Noop. Just here to satisfy backwards compatibility demands. + void set_gettimeofday (ACE_Time_Value (*gettimeofday)(void)); }; /** @@ -48,6 +51,9 @@ class ACE_Export ACE_HR_Time_Policy public: /// Return the current time according to this policy ACE_Time_Value operator() () const; + + /// Noop. Just here to satisfy backwards compatibility demands. + void set_gettimeofday (ACE_Time_Value (*gettimeofday)(void)); }; /** @@ -88,7 +94,8 @@ public: /// Return the current time according to this policy ACE_Time_Value operator()() const; - + /// Satisfy backwards compatibility demands. + void set_gettimeofday (ACE_Time_Value (*gettimeofday)(void)); private: FPtr function_; }; @@ -108,6 +115,8 @@ public: /// Return the current time according to this policy ACE_Time_Value operator()() const; + /// Noop. Just here to satisfy backwards compatibility demands. + void set_gettimeofday (ACE_Time_Value (*gettimeofday)(void)); protected: /// Return the current time according to policy implementation. virtual ACE_Time_Value gettimeofday () const = 0; @@ -134,6 +143,8 @@ public: /// Copy policy ACE_Delegating_Time_Policy& operator =(ACE_Delegating_Time_Policy const & pol); + /// Noop. Just here to satisfy backwards compatibility demands. + void set_gettimeofday (ACE_Time_Value (*gettimeofday)(void)); private: ACE_Dynamic_Time_Policy_Base const * delegate_; @@ -146,6 +157,11 @@ private: static NULL_Time_Policy null_policy_; }; +/// Temporarily, for backwards compatibility reasons, this will +/// be the default time policy. In time to be replaced by +/// ACE_System_Time_Policy. +typedef ACE_FPointer_Time_Policy ACE_Default_Time_Policy; + ACE_END_VERSIONED_NAMESPACE_DECL #if defined (__ACE_INLINE__) diff --git a/ACE/ace/Time_Policy.inl b/ACE/ace/Time_Policy.inl index 10d28730a29..19fd9c6c206 100644 --- a/ACE/ace/Time_Policy.inl +++ b/ACE/ace/Time_Policy.inl @@ -8,17 +8,27 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ACE_Time_Value -ACE_Default_Time_Policy::operator()() const +ACE_System_Time_Policy::operator()() const { return ACE_OS::gettimeofday(); } +ACE_INLINE void +ACE_System_Time_Policy::set_gettimeofday (ACE_Time_Value (*)(void)) +{ +} + ACE_INLINE ACE_Time_Value ACE_HR_Time_Policy::operator()() const { return ACE_High_Res_Timer::gettimeofday_hr (); } +ACE_INLINE void +ACE_HR_Time_Policy::set_gettimeofday (ACE_Time_Value (*)(void)) +{ +} + ACE_INLINE ACE_FPointer_Time_Policy::ACE_FPointer_Time_Policy() : function_(ACE_OS::gettimeofday) @@ -38,12 +48,23 @@ ACE_FPointer_Time_Policy::operator()() const return (*this->function_)(); } +ACE_INLINE void +ACE_FPointer_Time_Policy::set_gettimeofday (ACE_Time_Value (*f)(void)) +{ + this->function_ = f; +} + ACE_INLINE ACE_Time_Value ACE_Dynamic_Time_Policy_Base::operator()() const { return this->gettimeofday (); } +ACE_INLINE void +ACE_Dynamic_Time_Policy_Base::set_gettimeofday (ACE_Time_Value (*)(void)) +{ +} + ACE_INLINE ACE_Delegating_Time_Policy::ACE_Delegating_Time_Policy (ACE_Dynamic_Time_Policy_Base const * delegate) : delegate_ (delegate != 0 ? delegate : &null_policy_) @@ -57,6 +78,11 @@ ACE_Delegating_Time_Policy::operator()() const } ACE_INLINE void +ACE_Delegating_Time_Policy::set_gettimeofday (ACE_Time_Value (*)(void)) +{ +} + +ACE_INLINE void ACE_Delegating_Time_Policy::set_delegate (ACE_Dynamic_Time_Policy_Base const * delegate) { if (delegate != 0) diff --git a/ACE/ace/Time_Policy_T.h b/ACE/ace/Time_Policy_T.h index fce00b36a13..7fc084be377 100644 --- a/ACE/ace/Time_Policy_T.h +++ b/ACE/ace/Time_Policy_T.h @@ -46,6 +46,8 @@ public: /// of day. void set_time_policy(TIME_POLICY const & time_policy); + /// Noop. Just here to satisfy backwards compatibility demands. + void set_gettimeofday (ACE_Time_Value (*gettimeofday)(void)); protected: /// Return the current time according to policy implementation. virtual ACE_Time_Value gettimeofday () const; diff --git a/ACE/ace/Time_Policy_T.inl b/ACE/ace/Time_Policy_T.inl index a110ee7057b..4d30d6c6fc5 100644 --- a/ACE/ace/Time_Policy_T.inl +++ b/ACE/ace/Time_Policy_T.inl @@ -17,6 +17,11 @@ ACE_Time_Policy_T<TIME_POLICY>::operator() () const } template <typename TIME_POLICY> ACE_INLINE void +ACE_Time_Policy_T<TIME_POLICY>::set_gettimeofday (ACE_Time_Value (*)(void)) +{ +} + +template <typename TIME_POLICY> ACE_INLINE void ACE_Time_Policy_T<TIME_POLICY>::set_time_policy(TIME_POLICY const & time_policy) { this->time_policy_ = time_policy; diff --git a/ACE/ace/Timer_Queue_T.cpp b/ACE/ace/Timer_Queue_T.cpp index 86f96bbeb95..d0de6d0c68a 100644 --- a/ACE/ace/Timer_Queue_T.cpp +++ b/ACE/ace/Timer_Queue_T.cpp @@ -68,6 +68,12 @@ ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::gettimeofday() return this->gettimeofday_static(); } +template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> void +ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::gettimeofday (ACE_Time_Value (*gettimeofday)(void)) +{ + this->time_policy_.set_gettimeofday (gettimeofday); +} + template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> ACE_Time_Value * ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::calculate_timeout (ACE_Time_Value *max_wait_time) { diff --git a/ACE/ace/Timer_Queue_T.h b/ACE/ace/Timer_Queue_T.h index c5d2a488329..609093e3450 100644 --- a/ACE/ace/Timer_Queue_T.h +++ b/ACE/ace/Timer_Queue_T.h @@ -126,6 +126,16 @@ public: virtual ACE_Time_Value gettimeofday (void); //@} + /** + * Allows applications to control how the timer queue gets the time + * of day. + * @deprecated Use TIME_POLICY support instead. + * This will only have effect when the TIME_POLICY used + * is ACE_FPointer_Time_Policy. Other standard ACE time + * policies will ignore this. + */ + virtual void gettimeofday (ACE_Time_Value (*gettimeofday)(void)); + /// Implement an inlined, non-abstract version of gettimeofday(), /// through this member function the internals of the class can /// make calls to ACE_OS::gettimeofday() with zero overhead. diff --git a/ACE/tests/Timer_Queue_Test.cpp b/ACE/tests/Timer_Queue_Test.cpp index be9514bc424..160613945e8 100644 --- a/ACE/tests/Timer_Queue_Test.cpp +++ b/ACE/tests/Timer_Queue_Test.cpp @@ -683,7 +683,7 @@ run_main (int argc, ACE_TCHAR *argv[]) ACE_Timer_Heap_Variable_Time_Source *tq_heap = new ACE_Timer_Heap_Variable_Time_Source; - tq_heap->set_time_policy(&ACE_High_Res_Timer::gettimeofday_hr); + tq_heap->gettimeofday(&ACE_High_Res_Timer::gettimeofday_hr); ACE_NEW_RETURN (tq_stack, Timer_Queue_Stack (tq_heap, ACE_TEXT ("ACE_Timer_Heap (high-res timer)"), |