diff options
author | mcorino <mcorino@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2012-08-16 09:36:07 +0000 |
---|---|---|
committer | mcorino <mcorino@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2012-08-16 09:36:07 +0000 |
commit | f25c7a2aa1e464b424ba5add600f9a3e0edc9ee2 (patch) | |
tree | 176c473ff67ebacacb932706101f3a4f46d352a4 /ACE/ace | |
parent | 22a406258b246f6f07610d38f749ba3a8c7cbd7e (diff) | |
download | ATCD-f25c7a2aa1e464b424ba5add600f9a3e0edc9ee2.tar.gz |
ChangeLogTag: Thu Aug 16 09:22:31 UTC 2012 Martin Corino <mcorino@remedy.nl>
Diffstat (limited to 'ACE/ace')
51 files changed, 1835 insertions, 1084 deletions
diff --git a/ACE/ace/Condition_Attributes.cpp b/ACE/ace/Condition_Attributes.cpp index 0203fc519c7..45534e0a7c3 100644 --- a/ACE/ace/Condition_Attributes.cpp +++ b/ACE/ace/Condition_Attributes.cpp @@ -9,6 +9,7 @@ * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> */ +#include "ace/Condition_Thread_Mutex.h" #include "ace/Condition_Attributes.h" #if defined (ACE_HAS_THREADS) diff --git a/ACE/ace/Condition_Attributes.h b/ACE/ace/Condition_Attributes.h index 9fd189fa0fc..0855276f5a8 100644 --- a/ACE/ace/Condition_Attributes.h +++ b/ACE/ace/Condition_Attributes.h @@ -39,8 +39,8 @@ public: /// Destructor ~ACE_Condition_Attributes (void); -private: - friend class ACE_Condition_Thread_Mutex; +protected: + template <class MUTEX> friend class ACE_Condition; /// The attributes ACE_condattr_t attributes_; @@ -51,6 +51,43 @@ private: ACE_Condition_Attributes (const ACE_Condition_Attributes &); }; +template <class TIME_POLICY> +class ACE_Condition_Attributes_T : public ACE_Condition_Attributes +{ +public: + /// Constructor + ACE_Condition_Attributes_T (int type = ACE_DEFAULT_SYNCH_TYPE) + : ACE_Condition_Attributes (type) + {} + + /// Destructor + ~ACE_Condition_Attributes_T (void) {} + +private: + // = Prevent assignment and initialization. + void operator= (const ACE_Condition_Attributes_T<TIME_POLICY> &); + ACE_Condition_Attributes_T (const ACE_Condition_Attributes_T<TIME_POLICY> &); +}; + +class ACE_Monotonic_Time_Policy; + +template <> +class ACE_Export ACE_Condition_Attributes_T<ACE_Monotonic_Time_Policy> + : public ACE_Condition_Attributes +{ +public: + /// Constructor + ACE_Condition_Attributes_T (int type = ACE_DEFAULT_SYNCH_TYPE); + + /// Destructor + ~ACE_Condition_Attributes_T (void); + +private: + // = Prevent assignment and initialization. + void operator= (const ACE_Condition_Attributes_T<ACE_Monotonic_Time_Policy> &); + ACE_Condition_Attributes_T (const ACE_Condition_Attributes_T<ACE_Monotonic_Time_Policy> &); +}; + ACE_END_VERSIONED_NAMESPACE_DECL #if defined (__ACE_INLINE__) diff --git a/ACE/ace/Condition_Attributes.inl b/ACE/ace/Condition_Attributes.inl index 362140a4e53..5d3e8f6d06a 100644 --- a/ACE/ace/Condition_Attributes.inl +++ b/ACE/ace/Condition_Attributes.inl @@ -16,4 +16,18 @@ ACE_Condition_Attributes::~ACE_Condition_Attributes (void) ACE_OS::condattr_destroy (this->attributes_); } +ACE_INLINE +ACE_Condition_Attributes_T<ACE_Monotonic_Time_Policy>::ACE_Condition_Attributes_T (int type) + : ACE_Condition_Attributes (type) +{ +#if (defined (_POSIX_MONOTONIC_CLOCK) && !defined (ACE_LACKS_MONOTONIC_TIME)) || defined (ACE_HAS_CLOCK_GETTIME_MONOTONIC) + (void) ACE_OS::condattr_setclock (this->attributes_, CLOCK_MONOTONIC); +#endif +} + +ACE_INLINE +ACE_Condition_Attributes_T<ACE_Monotonic_Time_Policy>::~ACE_Condition_Attributes_T (void) +{ +} + ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Condition_Recursive_Thread_Mutex.cpp b/ACE/ace/Condition_Recursive_Thread_Mutex.cpp index 01607d8c52c..db5cecf02f1 100644 --- a/ACE/ace/Condition_Recursive_Thread_Mutex.cpp +++ b/ACE/ace/Condition_Recursive_Thread_Mutex.cpp @@ -14,9 +14,7 @@ #if defined (ACE_HAS_THREADS) -#if defined (ACE_HAS_DUMP) -# include "ace/Log_Msg.h" -#endif /* ACE_HAS_DUMP */ +#include "ace/Log_Msg.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -49,7 +47,19 @@ ACE_Condition<ACE_Recursive_Thread_Mutex>::~ACE_Condition (void) ACE_Condition<ACE_Recursive_Thread_Mutex>::ACE_Condition (ACE_Recursive_Thread_Mutex &m) : mutex_ (m) { - ACE_OS::cond_init (&this->cond_); + if (ACE_OS::cond_init (&this->cond_) != 0) + ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Condition<ACE_Recursive_Thread_Mutex>::ACE_Condition<ACE_Recursive_Thread_Mutex>"))); +} + +ACE_Condition<ACE_Recursive_Thread_Mutex>::ACE_Condition (ACE_Recursive_Thread_Mutex &m, + const ACE_Condition_Attributes &attributes) + : mutex_ (m) +{ + if (ACE_OS::cond_init (&this->cond_, + const_cast<ACE_Condition_Attributes &> (attributes).attributes_) != 0) + ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Condition<ACE_Recursive_Thread_Mutex>::ACE_Condition<ACE_Recursive_Thread_Mutex>"))); } int @@ -118,12 +128,6 @@ ACE_Condition<ACE_Recursive_Thread_Mutex>::mutex (void) return this->mutex_; } -ACE_Condition_Recursive_Thread_Mutex::ACE_Condition_Recursive_Thread_Mutex ( - ACE_Recursive_Thread_Mutex &m) : - ACE_Condition<ACE_Recursive_Thread_Mutex> (m) -{ -} - ACE_END_VERSIONED_NAMESPACE_DECL #endif /* ACE_HAS_THREADS */ diff --git a/ACE/ace/Condition_Recursive_Thread_Mutex.h b/ACE/ace/Condition_Recursive_Thread_Mutex.h index 4b8627868d8..077b9eaec1a 100644 --- a/ACE/ace/Condition_Recursive_Thread_Mutex.h +++ b/ACE/ace/Condition_Recursive_Thread_Mutex.h @@ -26,6 +26,7 @@ # include "ace/Null_Condition.h" #else /* ACE_HAS_THREADS */ #include "ace/Recursive_Thread_Mutex.h" +#include "ace/Condition_Attributes.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -43,6 +44,10 @@ public: /// Initialize the condition variable with a recursive mutex. ACE_Condition (ACE_Recursive_Thread_Mutex &m); + /// Initialize the condition variable. + ACE_Condition (ACE_Recursive_Thread_Mutex &m, + const ACE_Condition_Attributes &attributes); + /// Implicitly destroy the condition variable. ~ACE_Condition (void); @@ -100,13 +105,7 @@ private: }; -class ACE_Export ACE_Condition_Recursive_Thread_Mutex - : public ACE_Condition<ACE_Recursive_Thread_Mutex> -{ -public: - /// Initialize the condition variable with a recursive mutex. - ACE_Condition_Recursive_Thread_Mutex (ACE_Recursive_Thread_Mutex &m); -}; +typedef ACE_Condition<ACE_Recursive_Thread_Mutex> ACE_Condition_Recursive_Thread_Mutex; ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Condition_T.cpp b/ACE/ace/Condition_T.cpp index cdfb6dd21bd..77b13df9807 100644 --- a/ACE/ace/Condition_T.cpp +++ b/ACE/ace/Condition_T.cpp @@ -73,6 +73,22 @@ ACE_Condition<MUTEX>::ACE_Condition (MUTEX &m, } template <class MUTEX> +ACE_Condition<MUTEX>::ACE_Condition (MUTEX &m, + const ACE_Condition_Attributes &attributes, + const ACE_TCHAR *name, + void *arg) + : mutex_ (m) +{ +// ACE_TRACE ("ACE_Condition<MUTEX>::ACE_Condition<MUTEX>"); + if (ACE_OS::cond_init (&this->cond_, + const_cast<ACE_Condition_Attributes &> (attributes).attributes_, + name, arg) != 0) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Condition::ACE_Condition"))); +} + +template <class MUTEX> ACE_Condition<MUTEX>::~ACE_Condition (void) { // ACE_TRACE ("ACE_Condition<MUTEX>::~ACE_Condition"); diff --git a/ACE/ace/Condition_T.h b/ACE/ace/Condition_T.h index 44a1f55fb91..b76a3c17d7c 100644 --- a/ACE/ace/Condition_T.h +++ b/ACE/ace/Condition_T.h @@ -18,7 +18,7 @@ #include /**/ "ace/pre.h" #include "ace/OS_NS_Thread.h" -#include "ace/Lock.h" +#include "ace/Condition_Attributes.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once @@ -58,6 +58,12 @@ public: ACE_Condition (MUTEX &m, int type = USYNC_THREAD, const ACE_TCHAR *name = 0, void *arg = 0); + /// Initialize the condition variable. + ACE_Condition (MUTEX &m, + const ACE_Condition_Attributes &attributes, + const ACE_TCHAR *name = 0, + void *arg = 0); + /// Implicitly destroy the condition variable. ~ACE_Condition (void); diff --git a/ACE/ace/Condition_Thread_Mutex.cpp b/ACE/ace/Condition_Thread_Mutex.cpp index 3ea09e6d3dd..f6b4d50eb10 100644 --- a/ACE/ace/Condition_Thread_Mutex.cpp +++ b/ACE/ace/Condition_Thread_Mutex.cpp @@ -21,13 +21,13 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_ALLOC_HOOK_DEFINE(ACE_Condition_Thread_Mutex) +ACE_ALLOC_HOOK_DEFINE(ACE_Condition<ACE_Thread_Mutex>) void -ACE_Condition_Thread_Mutex::dump (void) const +ACE_Condition<ACE_Thread_Mutex>::dump (void) const { #if defined (ACE_HAS_DUMP) -// ACE_TRACE ("ACE_Condition_Thread_Mutex::dump"); +// ACE_TRACE ("ACE_Condition<ACE_Thread_Mutex>::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); @@ -40,40 +40,40 @@ ACE_Condition_Thread_Mutex::dump (void) const #endif /* ACE_HAS_DUMP */ } -ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex (ACE_Thread_Mutex &m, - const ACE_TCHAR *name, - void *arg) +ACE_Condition<ACE_Thread_Mutex>::ACE_Condition (ACE_Thread_Mutex &m, + const ACE_TCHAR *name, + void *arg) : mutex_ (m), removed_ (false) { -// ACE_TRACE ("ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex"); +// ACE_TRACE ("ACE_Condition<ACE_Thread_Mutex>::ACE_Condition<ACE_Thread_Mutex>"); if (ACE_OS::cond_init (&this->cond_, (short) USYNC_THREAD, name, arg) != 0) ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex"))); + ACE_TEXT ("ACE_Condition<ACE_Thread_Mutex>::ACE_Condition<ACE_Thread_Mutex>"))); } -ACE_Condition_Thread_Mutex:: -ACE_Condition_Thread_Mutex (ACE_Thread_Mutex &m, - ACE_Condition_Attributes &attributes, - const ACE_TCHAR *name, - void *arg) +ACE_Condition<ACE_Thread_Mutex>::ACE_Condition (ACE_Thread_Mutex &m, + const ACE_Condition_Attributes &attributes, + const ACE_TCHAR *name, + void *arg) : mutex_ (m), removed_ (false) { -// ACE_TRACE ("ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex"); - if (ACE_OS::cond_init (&this->cond_, attributes.attributes_, +// ACE_TRACE ("ACE_Condition<ACE_Thread_Mutex>::ACE_Condition<ACE_Thread_Mutex>"); + if (ACE_OS::cond_init (&this->cond_, + const_cast<ACE_Condition_Attributes &> (attributes).attributes_, name, arg) != 0) ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), - ACE_TEXT ("ACE_Condition_Thread_Mutex::ACE_Condition_Thread_Mutex"))); + ACE_TEXT ("ACE_Condition<ACE_Thread_Mutex>::ACE_Condition<ACE_Thread_Mutex>"))); } -ACE_Condition_Thread_Mutex::~ACE_Condition_Thread_Mutex (void) +ACE_Condition<ACE_Thread_Mutex>::~ACE_Condition (void) { -// ACE_TRACE ("ACE_Condition_Thread_Mutex::~ACE_Condition_Thread_Mutex"); +// ACE_TRACE ("ACE_Condition<ACE_Thread_Mutex>::~ACE_Condition<ACE_Thread_Mutex>"); this->remove (); } @@ -82,40 +82,40 @@ ACE_Condition_Thread_Mutex::~ACE_Condition_Thread_Mutex (void) // <abstime> using the <cond_timedwait> function. int -ACE_Condition_Thread_Mutex::wait (void) +ACE_Condition<ACE_Thread_Mutex>::wait (void) { -// ACE_TRACE ("ACE_Condition_Thread_Mutex::wait"); - return ACE_OS::cond_wait (&this->cond_, &this->mutex_.lock_); +// ACE_TRACE ("ACE_Condition<ACE_Thread_Mutex>::wait"); + return ACE_OS::cond_wait (&this->cond_, &this->mutex_.lock ()); } int -ACE_Condition_Thread_Mutex::wait (ACE_Thread_Mutex &mutex, +ACE_Condition<ACE_Thread_Mutex>::wait (ACE_Thread_Mutex &mutex, const ACE_Time_Value *abstime) { -// ACE_TRACE ("ACE_Condition_Thread_Mutex::wait"); +// ACE_TRACE ("ACE_Condition<ACE_Thread_Mutex>::wait"); return ACE_OS::cond_timedwait (&this->cond_, - &mutex.lock_, + &mutex.lock (), const_cast <ACE_Time_Value *> (abstime)); } int -ACE_Condition_Thread_Mutex::wait (const ACE_Time_Value *abstime) +ACE_Condition<ACE_Thread_Mutex>::wait (const ACE_Time_Value *abstime) { -// ACE_TRACE ("ACE_Condition_Thread_Mutex::wait"); +// ACE_TRACE ("ACE_Condition<ACE_Thread_Mutex>::wait"); return this->wait (this->mutex_, abstime); } int -ACE_Condition_Thread_Mutex::signal (void) +ACE_Condition<ACE_Thread_Mutex>::signal (void) { -// ACE_TRACE ("ACE_Condition_Thread_Mutex::signal"); +// ACE_TRACE ("ACE_Condition<ACE_Thread_Mutex>::signal"); return ACE_OS::cond_signal (&this->cond_); } int -ACE_Condition_Thread_Mutex::broadcast (void) +ACE_Condition<ACE_Thread_Mutex>::broadcast (void) { -// ACE_TRACE ("ACE_Condition_Thread_Mutex::broadcast"); +// ACE_TRACE ("ACE_Condition<ACE_Thread_Mutex>::broadcast"); return ACE_OS::cond_broadcast (&this->cond_); } diff --git a/ACE/ace/Condition_Thread_Mutex.h b/ACE/ace/Condition_Thread_Mutex.h index b5a7ff20e21..d43541346d8 100644 --- a/ACE/ace/Condition_Thread_Mutex.h +++ b/ACE/ace/Condition_Thread_Mutex.h @@ -32,13 +32,14 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL +template <class ACE_LOCK> class ACE_Condition; + class ACE_Time_Value; /** - * @class ACE_Condition_Thread_Mutex - * - * @brief ACE_Condition variable wrapper written using ACE_Mutexes. This - * allows threads to block until shared data changes state. + * @brief ACE_Condition template specialization written using + * ACE_Mutexes. This allows threads to block until shared data + * changes state. * A condition variable enables threads to atomically block and * test the condition under the protection of a mutual exclu- * sion lock (mutex) until the condition is satisfied. That is, @@ -50,26 +51,24 @@ class ACE_Time_Value; * up waiting threads by signaling the associated condition * variable. The waiting threads, upon awakening, reacquire the * mutex and re-evaluate the condition. - * - * This should be an instantiation of ACE_Condition but problems - * with compilers precludes this... */ -class ACE_Export ACE_Condition_Thread_Mutex +template <> +class ACE_Export ACE_Condition<ACE_Thread_Mutex> { public: /// Initialize the condition variable. - ACE_Condition_Thread_Mutex (ACE_Thread_Mutex &m, - const ACE_TCHAR *name = 0, - void *arg = 0); + ACE_Condition (ACE_Thread_Mutex &m, + const ACE_TCHAR *name = 0, + void *arg = 0); /// Initialize the condition variable. - ACE_Condition_Thread_Mutex (ACE_Thread_Mutex &m, - ACE_Condition_Attributes &attributes, - const ACE_TCHAR *name = 0, - void *arg = 0); + ACE_Condition (ACE_Thread_Mutex &m, + const ACE_Condition_Attributes &attributes, + const ACE_TCHAR *name = 0, + void *arg = 0); /// Implicitly destroy the condition variable. - ~ACE_Condition_Thread_Mutex (void); + ~ACE_Condition (void); /** * Explicitly destroy the condition variable. Note that only one @@ -130,10 +129,12 @@ protected: private: // = Prevent assignment and initialization. - void operator= (const ACE_Condition_Thread_Mutex &); - ACE_Condition_Thread_Mutex (const ACE_Condition_Thread_Mutex &); + void operator= (const ACE_Condition<ACE_Thread_Mutex> &); + ACE_Condition (const ACE_Condition<ACE_Thread_Mutex> &); }; +typedef ACE_Condition<ACE_Thread_Mutex> ACE_Condition_Thread_Mutex; + ACE_END_VERSIONED_NAMESPACE_DECL #if defined (__ACE_INLINE__) diff --git a/ACE/ace/Condition_Thread_Mutex.inl b/ACE/ace/Condition_Thread_Mutex.inl index f7a4a0380ee..3a60a15cdf3 100644 --- a/ACE/ace/Condition_Thread_Mutex.inl +++ b/ACE/ace/Condition_Thread_Mutex.inl @@ -5,9 +5,9 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int -ACE_Condition_Thread_Mutex::remove (void) +ACE_Condition<ACE_Thread_Mutex>::remove (void) { -// ACE_TRACE ("ACE_Condition_Thread_Mutex::remove"); +// ACE_TRACE ("ACE_Condition<ACE_Thread_Mutex>::remove"); // <cond_destroy> is called in a loop if the condition variable is // BUSY. This avoids a condition where a condition is signaled and @@ -32,9 +32,9 @@ ACE_Condition_Thread_Mutex::remove (void) } ACE_INLINE ACE_Thread_Mutex & -ACE_Condition_Thread_Mutex::mutex (void) +ACE_Condition<ACE_Thread_Mutex>::mutex (void) { -// ACE_TRACE ("ACE_Condition_Thread_Mutex::mutex"); +// ACE_TRACE ("ACE_Condition<ACE_Thread_Mutex>::mutex"); return this->mutex_; } diff --git a/ACE/ace/Message_Queue.h b/ACE/ace/Message_Queue.h index 0fb424b52e4..a3e9beca101 100644 --- a/ACE/ace/Message_Queue.h +++ b/ACE/ace/Message_Queue.h @@ -26,8 +26,8 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL // Forward decls. class ACE_Notification_Strategy; -template <ACE_SYNCH_DECL> class ACE_Message_Queue_Iterator; -template <ACE_SYNCH_DECL> class ACE_Message_Queue_Reverse_Iterator; +template <ACE_SYNCH_DECL, class TIME_POLICY> class ACE_Message_Queue_Iterator; +template <ACE_SYNCH_DECL, class TIME_POLICY> class ACE_Message_Queue_Reverse_Iterator; /** * @class ACE_Message_Queue_Base diff --git a/ACE/ace/Message_Queue_T.cpp b/ACE/ace/Message_Queue_T.cpp index 75fe241a1fa..b80c7f7372e 100644 --- a/ACE/ace/Message_Queue_T.cpp +++ b/ACE/ace/Message_Queue_T.cpp @@ -20,6 +20,7 @@ #include "ace/Notification_Strategy.h" #include "ace/Truncate.h" +#include "ace/Condition_Attributes.h" #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) #include "ace/OS_NS_stdio.h" @@ -34,93 +35,93 @@ ACE_ALLOC_HOOK_DEFINE(ACE_Dynamic_Message_Queue) ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Ex) ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Ex_N) -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> void -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dump (void) const +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> void +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::dump (void) const { #if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dump"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::dump"); this->queue_.dump (); #endif /* ACE_HAS_DUMP */ } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> void -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::message_bytes (size_t new_value) +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> void +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::message_bytes (size_t new_value) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::message_bytes"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::message_bytes"); this->queue_.message_bytes (new_value); } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> void -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::message_length (size_t new_value) +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> void +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::message_length (size_t new_value) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::message_length"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::message_length"); this->queue_.message_length (new_value); } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::ACE_Message_Queue_Ex (size_t high_water_mark, +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::ACE_Message_Queue_Ex (size_t high_water_mark, size_t low_water_mark, ACE_Notification_Strategy *ns) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::ACE_Message_Queue_Ex"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::ACE_Message_Queue_Ex"); if (this->queue_.open (high_water_mark, low_water_mark, ns) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("ACE_Message_Queue_Ex"))); } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::~ACE_Message_Queue_Ex (void) +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::~ACE_Message_Queue_Ex (void) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::~ACE_Message_Queue_Ex"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::~ACE_Message_Queue_Ex"); } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::open (size_t hwm, +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::open (size_t hwm, size_t lwm, ACE_Notification_Strategy *ns) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::open"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::open"); return this->queue_.open (hwm, lwm, ns); } // Clean up the queue if we have not already done so! -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::close (void) +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::close (void) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::close"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::close"); return this->queue_.close (); } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::flush (void) +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::flush (void) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::flush"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::flush"); return this->queue_.flush (); } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::flush_i (void) +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::flush_i (void) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::flush_i"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::flush_i"); return this->queue_.flush_i (); } // Take a look at the first item without removing it. -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::peek_dequeue_head (ACE_MESSAGE_TYPE *&first_item, +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::peek_dequeue_head (ACE_MESSAGE_TYPE *&first_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::peek_dequeue_head"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::peek_dequeue_head"); ACE_Message_Block *mb = 0; @@ -132,18 +133,18 @@ ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::peek_dequeue_head (ACE_ME return cur_count; } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_head (ACE_MESSAGE_TYPE *new_item, +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::enqueue_head (ACE_MESSAGE_TYPE *new_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_head"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::enqueue_head"); ACE_Message_Block *mb = 0; ACE_NEW_RETURN (mb, ACE_Message_Block ((char *) new_item, sizeof (*new_item), - ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::DEFAULT_PRIORITY), + ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::DEFAULT_PRIORITY), -1); int const result = this->queue_.enqueue_head (mb, timeout); @@ -157,21 +158,21 @@ ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_head (ACE_MESSAGE // accordance with its <msg_priority> (0 is lowest priority). Returns // -1 on failure, else the number of items still on the queue. -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue (ACE_MESSAGE_TYPE *new_item, +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::enqueue (ACE_MESSAGE_TYPE *new_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::enqueue"); return this->enqueue_prio (new_item, timeout); } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_prio (ACE_MESSAGE_TYPE *new_item, +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::enqueue_prio (ACE_MESSAGE_TYPE *new_item, ACE_Time_Value *timeout, unsigned long priority) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_prio"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::enqueue_prio"); ACE_Message_Block *mb = 0; @@ -189,18 +190,18 @@ ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_prio (ACE_MESSAGE return result; } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_deadline (ACE_MESSAGE_TYPE *new_item, +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::enqueue_deadline (ACE_MESSAGE_TYPE *new_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_deadline"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::enqueue_deadline"); ACE_Message_Block *mb = 0; ACE_NEW_RETURN (mb, ACE_Message_Block ((char *) new_item, sizeof (*new_item), - ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::DEFAULT_PRIORITY ), + ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::DEFAULT_PRIORITY ), -1); int const result = this->queue_.enqueue_deadline (mb, timeout); @@ -214,18 +215,18 @@ ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_deadline (ACE_MES // Block indefinitely waiting for an item to arrive, // does not ignore alerts (e.g., signals). -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_tail (ACE_MESSAGE_TYPE *new_item, +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::enqueue_tail (ACE_MESSAGE_TYPE *new_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_tail"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::enqueue_tail"); ACE_Message_Block *mb = 0; ACE_NEW_RETURN (mb, ACE_Message_Block ((char *) new_item, sizeof (*new_item), - ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::DEFAULT_PRIORITY), + ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::DEFAULT_PRIORITY), -1); int const result = this->queue_.enqueue_tail (mb, timeout); @@ -239,11 +240,11 @@ ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_tail (ACE_MESSAGE // indefinitely (or until an alert occurs). Otherwise, block for upto // the amount of time specified by timeout. -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dequeue_head (ACE_MESSAGE_TYPE *&first_item, +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::dequeue_head (ACE_MESSAGE_TYPE *&first_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dequeue_head"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::dequeue_head"); ACE_Message_Block *mb = 0; @@ -264,11 +265,11 @@ ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dequeue_head (ACE_MESSAGE // block indefinitely (or until an alert occurs). Otherwise, block for upto // the amount of time specified by timeout. -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dequeue_prio (ACE_MESSAGE_TYPE *&dequeued, +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::dequeue_prio (ACE_MESSAGE_TYPE *&dequeued, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dequeue_prio"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::dequeue_prio"); ACE_Message_Block *mb = 0; @@ -289,11 +290,11 @@ ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dequeue_prio (ACE_MESSAGE // indefinitely (or until an alert occurs). Otherwise, block for upto // the amount of time specified by timeout. -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dequeue_tail (ACE_MESSAGE_TYPE *&dequeued, +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::dequeue_tail (ACE_MESSAGE_TYPE *&dequeued, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dequeue_tail"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::dequeue_tail"); ACE_Message_Block *mb = 0; @@ -314,11 +315,11 @@ ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dequeue_tail (ACE_MESSAGE // indefinitely (or until an alert occurs). Otherwise, block for upto // the amount of time specified by timeout. -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dequeue_deadline (ACE_MESSAGE_TYPE *&dequeued, +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::dequeue_deadline (ACE_MESSAGE_TYPE *&dequeued, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dequeue_deadline"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::dequeue_deadline"); ACE_Message_Block *mb = 0; @@ -335,24 +336,24 @@ ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dequeue_deadline (ACE_MES return cur_count; } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::notify (void) +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::notify (void) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::notify"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::notify"); return this->queue_.notify (); } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> -ACE_Message_Queue_Ex_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>:: -ACE_Message_Queue_Ex_Iterator (ACE_Message_Queue_Ex <ACE_MESSAGE_TYPE, ACE_SYNCH_USE> & queue) +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Message_Queue_Ex_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>:: +ACE_Message_Queue_Ex_Iterator (ACE_Message_Queue_Ex <ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY> & queue) : iter_ (queue.queue_) { } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int -ACE_Message_Queue_Ex_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>:: +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Ex_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>:: next (ACE_MESSAGE_TYPE *&entry) { ACE_Message_Block * mb = 0; @@ -364,36 +365,36 @@ next (ACE_MESSAGE_TYPE *&entry) return retval; } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int -ACE_Message_Queue_Ex_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::done (void) const +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Ex_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::done (void) const { return this->iter_.done (); } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int -ACE_Message_Queue_Ex_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::advance (void) +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Ex_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::advance (void) { return this->iter_.advance (); } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> void -ACE_Message_Queue_Ex_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dump (void) const +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> void +ACE_Message_Queue_Ex_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::dump (void) const { this->iter_.dump (); } ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Ex_Iterator) -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> -ACE_Message_Queue_Ex_Reverse_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>:: -ACE_Message_Queue_Ex_Reverse_Iterator (ACE_Message_Queue_Ex <ACE_MESSAGE_TYPE, ACE_SYNCH_USE> & queue) +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Message_Queue_Ex_Reverse_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>:: +ACE_Message_Queue_Ex_Reverse_Iterator (ACE_Message_Queue_Ex <ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY> & queue) : iter_ (queue.queue_) { } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int -ACE_Message_Queue_Ex_Reverse_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>:: +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Ex_Reverse_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>:: next (ACE_MESSAGE_TYPE *&entry) { ACE_Message_Block * mb = 0; @@ -405,50 +406,50 @@ next (ACE_MESSAGE_TYPE *&entry) return retval; } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int -ACE_Message_Queue_Ex_Reverse_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::done (void) const +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Ex_Reverse_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::done (void) const { return this->iter_.done (); } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int -ACE_Message_Queue_Ex_Reverse_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::advance (void) +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Ex_Reverse_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::advance (void) { return this->iter_.advance (); } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> void -ACE_Message_Queue_Ex_Reverse_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dump (void) const +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> void +ACE_Message_Queue_Ex_Reverse_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::dump (void) const { this->iter_.dump (); } ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Ex_Reverse_Iterator) -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> -ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::ACE_Message_Queue_Ex_N +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::ACE_Message_Queue_Ex_N (size_t high_water_mark, size_t low_water_mark, ACE_Notification_Strategy *ns): - ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE> (high_water_mark, + ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY> (high_water_mark, low_water_mark, ns) { - ACE_TRACE ("ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::ACE_Message_Queue_Ex_N"); + ACE_TRACE ("ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::ACE_Message_Queue_Ex_N"); } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> -ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::~ACE_Message_Queue_Ex_N (void) +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::~ACE_Message_Queue_Ex_N (void) { - ACE_TRACE ("ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::~ACE_Message_Queue_Ex_N"); + ACE_TRACE ("ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::~ACE_Message_Queue_Ex_N"); } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int -ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_head +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::enqueue_head (ACE_MESSAGE_TYPE *new_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_head"); + ACE_TRACE ("ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::enqueue_head"); // Create a chained ACE_Message_Blocks wrappers around the 'chained' // ACE_MESSAGE_TYPES. @@ -467,12 +468,12 @@ ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_head return result; } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int -ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_tail +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::enqueue_tail (ACE_MESSAGE_TYPE *new_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_tail"); + ACE_TRACE ("ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::enqueue_tail"); // Create a chained ACE_Message_Blocks wrappers around the 'chained' // ACE_MESSAGE_TYPES. @@ -491,11 +492,11 @@ ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_tail return result; } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> ACE_Message_Block * -ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::wrap_with_mbs_i +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> ACE_Message_Block * +ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::wrap_with_mbs_i (ACE_MESSAGE_TYPE *new_item) { - ACE_TRACE ("ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::wrap_with_mbs_i"); + ACE_TRACE ("ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::wrap_with_mbs_i"); // We need to keep a reference to the head of the chain ACE_Message_Block *mb_head = 0; @@ -503,7 +504,7 @@ ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::wrap_with_mbs_i ACE_NEW_RETURN (mb_head, ACE_Message_Block ((char *) new_item, sizeof (*new_item), - ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::DEFAULT_PRIORITY), + ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::DEFAULT_PRIORITY), 0); // mb_tail will point to the last ACE_Message_Block @@ -516,7 +517,7 @@ ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::wrap_with_mbs_i ACE_NEW_NORETURN (mb_temp, ACE_Message_Block ((char *) pobj, sizeof (*pobj), - ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::DEFAULT_PRIORITY)); + ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::DEFAULT_PRIORITY)); if (mb_temp == 0) { mb_head->release (); @@ -533,162 +534,176 @@ ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::wrap_with_mbs_i ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Reverse_Iterator) -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dequeue (ACE_MESSAGE_TYPE *&first_item, +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::dequeue (ACE_MESSAGE_TYPE *&first_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dequeue"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::dequeue"); return this->dequeue_head (first_item, timeout); } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> ACE_Notification_Strategy * -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::notification_strategy (void) +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> ACE_Notification_Strategy * +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::notification_strategy (void) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::notification_strategy"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::notification_strategy"); return this->queue_.notification_strategy (); } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> void -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::notification_strategy (ACE_Notification_Strategy *s) +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> void +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::notification_strategy (ACE_Notification_Strategy *s) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::notification_strategy"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::notification_strategy"); this->queue_.notification_strategy (s); } // Check if queue is empty (holds locks). -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> bool -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::is_empty (void) +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> bool +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::is_empty (void) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::is_empty"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::is_empty"); return this->queue_.is_empty (); } // Check if queue is full (holds locks). -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> bool -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::is_full (void) +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> bool +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::is_full (void) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::is_full"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::is_full"); return this->queue_.is_full (); } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> size_t -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::high_water_mark (void) +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> size_t +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::high_water_mark (void) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::high_water_mark"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::high_water_mark"); return this->queue_.high_water_mark (); } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> void -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::high_water_mark (size_t hwm) +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> void +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::high_water_mark (size_t hwm) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::high_water_mark"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::high_water_mark"); this->queue_.high_water_mark (hwm); } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> size_t -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::low_water_mark (void) +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> size_t +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::low_water_mark (void) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::low_water_mark"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::low_water_mark"); return this->queue_.low_water_mark (); } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> void -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::low_water_mark (size_t lwm) +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> void +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::low_water_mark (size_t lwm) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::low_water_mark"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::low_water_mark"); this->queue_.low_water_mark (lwm); } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> size_t -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::message_bytes (void) +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> size_t +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::message_bytes (void) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::message_bytes"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::message_bytes"); return this->queue_.message_bytes (); } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> size_t -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::message_length (void) +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> size_t +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::message_length (void) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::message_length"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::message_length"); return this->queue_.message_length (); } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> size_t -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::message_count (void) +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> size_t +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::message_count (void) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::message_count"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::message_count"); return this->queue_.message_count (); } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::deactivate (void) +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::deactivate (void) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::deactivate"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::deactivate"); return this->queue_.deactivate (); } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::activate (void) +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::activate (void) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::activate"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::activate"); return this->queue_.activate (); } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::pulse (void) +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::pulse (void) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::pulse"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::pulse"); return this->queue_.pulse (); } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::deactivated (void) +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::deactivated (void) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::deactivated"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::deactivated"); return this->queue_.deactivated (); } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> int -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::state (void) +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::state (void) { - ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::state"); + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::state"); return this->queue_.state (); } -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> ACE_SYNCH_MUTEX_T & -ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::lock (void) +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> ACE_SYNCH_MUTEX_T & +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::lock (void) { return this->queue_.lock (); } -template <ACE_SYNCH_DECL> -ACE_Message_Queue_Iterator<ACE_SYNCH_USE>::ACE_Message_Queue_Iterator (ACE_Message_Queue <ACE_SYNCH_USE> &q) +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Time_Value_T<TIME_POLICY> +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::gettimeofday () +{ + return this->queue_.gettimeofday (); +} + +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> +void +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::set_time_policy (TIME_POLICY const & rhs) +{ + this->queue_.set_time_policy (rhs); +} + +template <ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Message_Queue_Iterator<ACE_SYNCH_USE, TIME_POLICY>::ACE_Message_Queue_Iterator (ACE_Message_Queue <ACE_SYNCH_USE, TIME_POLICY> &q) : queue_ (q), curr_ (q.head_) { } -template <ACE_SYNCH_DECL> int -ACE_Message_Queue_Iterator<ACE_SYNCH_USE>::next (ACE_Message_Block *&entry) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Iterator<ACE_SYNCH_USE, TIME_POLICY>::next (ACE_Message_Block *&entry) { ACE_READ_GUARD_RETURN (ACE_SYNCH_MUTEX_T, m, this->queue_.lock_, -1) @@ -701,16 +716,16 @@ ACE_Message_Queue_Iterator<ACE_SYNCH_USE>::next (ACE_Message_Block *&entry) return 0; } -template <ACE_SYNCH_DECL> int -ACE_Message_Queue_Iterator<ACE_SYNCH_USE>::done (void) const +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Iterator<ACE_SYNCH_USE, TIME_POLICY>::done (void) const { ACE_READ_GUARD_RETURN (ACE_SYNCH_MUTEX_T, m, this->queue_.lock_, -1) return this->curr_ == 0; } -template <ACE_SYNCH_DECL> int -ACE_Message_Queue_Iterator<ACE_SYNCH_USE>::advance (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Iterator<ACE_SYNCH_USE, TIME_POLICY>::advance (void) { ACE_READ_GUARD_RETURN (ACE_SYNCH_MUTEX_T, m, this->queue_.lock_, -1) @@ -719,8 +734,8 @@ ACE_Message_Queue_Iterator<ACE_SYNCH_USE>::advance (void) return this->curr_ != 0; } -template <ACE_SYNCH_DECL> void -ACE_Message_Queue_Iterator<ACE_SYNCH_USE>::dump (void) const +template <ACE_SYNCH_DECL, class TIME_POLICY> void +ACE_Message_Queue_Iterator<ACE_SYNCH_USE, TIME_POLICY>::dump (void) const { #if defined (ACE_HAS_DUMP) #endif /* ACE_HAS_DUMP */ @@ -728,15 +743,15 @@ ACE_Message_Queue_Iterator<ACE_SYNCH_USE>::dump (void) const ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Iterator) -template <ACE_SYNCH_DECL> -ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_USE>::ACE_Message_Queue_Reverse_Iterator (ACE_Message_Queue <ACE_SYNCH_USE> &q) +template <ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_USE, TIME_POLICY>::ACE_Message_Queue_Reverse_Iterator (ACE_Message_Queue <ACE_SYNCH_USE, TIME_POLICY> &q) : queue_ (q), curr_ (queue_.tail_) { } -template <ACE_SYNCH_DECL> int -ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_USE>::next (ACE_Message_Block *&entry) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_USE, TIME_POLICY>::next (ACE_Message_Block *&entry) { ACE_READ_GUARD_RETURN (ACE_SYNCH_MUTEX_T, m, this->queue_.lock_, -1) @@ -749,16 +764,16 @@ ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_USE>::next (ACE_Message_Block *&ent return 0; } -template <ACE_SYNCH_DECL> int -ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_USE>::done (void) const +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_USE, TIME_POLICY>::done (void) const { ACE_READ_GUARD_RETURN (ACE_SYNCH_MUTEX_T, m, this->queue_.lock_, -1) return this->curr_ == 0; } -template <ACE_SYNCH_DECL> int -ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_USE>::advance (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_USE, TIME_POLICY>::advance (void) { ACE_READ_GUARD_RETURN (ACE_SYNCH_MUTEX_T, m, this->queue_.lock_, -1) @@ -767,61 +782,61 @@ ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_USE>::advance (void) return this->curr_ != 0; } -template <ACE_SYNCH_DECL> void -ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_USE>::dump (void) const +template <ACE_SYNCH_DECL, class TIME_POLICY> void +ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_USE, TIME_POLICY>::dump (void) const { #if defined (ACE_HAS_DUMP) #endif /* ACE_HAS_DUMP */ } -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::dequeue (ACE_Message_Block *&first_item, +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::dequeue (ACE_Message_Block *&first_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::dequeue"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::dequeue"); return this->dequeue_head (first_item, timeout); } -template <ACE_SYNCH_DECL> ACE_Notification_Strategy * -ACE_Message_Queue<ACE_SYNCH_USE>::notification_strategy (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_Notification_Strategy * +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::notification_strategy (void) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::notification_strategy"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::notification_strategy"); return this->notification_strategy_; } -template <ACE_SYNCH_DECL> void -ACE_Message_Queue<ACE_SYNCH_USE>::notification_strategy (ACE_Notification_Strategy *s) +template <ACE_SYNCH_DECL, class TIME_POLICY> void +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::notification_strategy (ACE_Notification_Strategy *s) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::notification_strategy"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::notification_strategy"); this->notification_strategy_ = s; } // Check if queue is empty (does not hold locks). -template <ACE_SYNCH_DECL> bool -ACE_Message_Queue<ACE_SYNCH_USE>::is_empty_i (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> bool +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::is_empty_i (void) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::is_empty_i"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::is_empty_i"); return this->tail_ == 0; } // Check if queue is full (does not hold locks). -template <ACE_SYNCH_DECL> bool -ACE_Message_Queue<ACE_SYNCH_USE>::is_full_i (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> bool +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::is_full_i (void) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::is_full_i"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::is_full_i"); return this->cur_bytes_ >= this->high_water_mark_; } // Check if queue is empty (holds locks). -template <ACE_SYNCH_DECL> bool -ACE_Message_Queue<ACE_SYNCH_USE>::is_empty (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> bool +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::is_empty (void) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::is_empty"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::is_empty"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, false); return this->is_empty_i (); @@ -829,132 +844,146 @@ ACE_Message_Queue<ACE_SYNCH_USE>::is_empty (void) // Check if queue is full (holds locks). -template <ACE_SYNCH_DECL> bool -ACE_Message_Queue<ACE_SYNCH_USE>::is_full (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> bool +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::is_full (void) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::is_full"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::is_full"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, false); return this->is_full_i (); } -template <ACE_SYNCH_DECL> size_t -ACE_Message_Queue<ACE_SYNCH_USE>::high_water_mark (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> size_t +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::high_water_mark (void) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::high_water_mark"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::high_water_mark"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, 0); return this->high_water_mark_; } -template <ACE_SYNCH_DECL> void -ACE_Message_Queue<ACE_SYNCH_USE>::high_water_mark (size_t hwm) +template <ACE_SYNCH_DECL, class TIME_POLICY> void +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::high_water_mark (size_t hwm) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::high_water_mark"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::high_water_mark"); ACE_GUARD (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_); this->high_water_mark_ = hwm; } -template <ACE_SYNCH_DECL> size_t -ACE_Message_Queue<ACE_SYNCH_USE>::low_water_mark (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> size_t +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::low_water_mark (void) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::low_water_mark"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::low_water_mark"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, 0); return this->low_water_mark_; } -template <ACE_SYNCH_DECL> void -ACE_Message_Queue<ACE_SYNCH_USE>::low_water_mark (size_t lwm) +template <ACE_SYNCH_DECL, class TIME_POLICY> void +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::low_water_mark (size_t lwm) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::low_water_mark"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::low_water_mark"); ACE_GUARD (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_); this->low_water_mark_ = lwm; } -template <ACE_SYNCH_DECL> size_t -ACE_Message_Queue<ACE_SYNCH_USE>::message_bytes (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> size_t +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::message_bytes (void) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::message_bytes"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::message_bytes"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, 0); return this->cur_bytes_; } -template <ACE_SYNCH_DECL> size_t -ACE_Message_Queue<ACE_SYNCH_USE>::message_length (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> size_t +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::message_length (void) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::message_length"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::message_length"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, 0); return this->cur_length_; } -template <ACE_SYNCH_DECL> size_t -ACE_Message_Queue<ACE_SYNCH_USE>::message_count (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> size_t +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::message_count (void) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::message_count"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::message_count"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, 0); return this->cur_count_; } -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::deactivate () +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::deactivate () { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::deactivate"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::deactivate"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); return this->deactivate_i (0); // Not a pulse } -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::activate (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::activate (void) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::activate"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::activate"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); return this->activate_i (); } -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::pulse () +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::pulse () { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::pulse"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::pulse"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); return this->deactivate_i (1); // Just a pulse } -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::deactivated (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::deactivated (void) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::deactivated"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::deactivated"); return this->state_ == ACE_Message_Queue_Base::DEACTIVATED; } -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::state (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::state (void) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::state"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::state"); return this->state_; } -template <ACE_SYNCH_DECL> ACE_SYNCH_MUTEX_T & -ACE_Message_Queue<ACE_SYNCH_USE>::lock (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_SYNCH_MUTEX_T & +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::lock (void) { return this->lock_; } -template <ACE_SYNCH_DECL> void -ACE_Message_Queue<ACE_SYNCH_USE>::dump (void) const +template <ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Time_Value_T<TIME_POLICY> +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::gettimeofday (void) const +{ + return this->time_policy_ (); +} + +template <ACE_SYNCH_DECL, class TIME_POLICY> +void +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::set_time_policy (TIME_POLICY const & rhs) +{ + this->time_policy_ = rhs; +} + +template <ACE_SYNCH_DECL, class TIME_POLICY> void +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::dump (void) const { #if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::dump"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); switch (this->state_) { @@ -994,32 +1023,32 @@ ACE_Message_Queue<ACE_SYNCH_USE>::dump (void) const #endif /* ACE_HAS_DUMP */ } -template <ACE_SYNCH_DECL> void -ACE_Message_Queue<ACE_SYNCH_USE>::message_bytes (size_t new_value) +template <ACE_SYNCH_DECL, class TIME_POLICY> void +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::message_bytes (size_t new_value) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::message_bytes"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::message_bytes"); ACE_GUARD (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_); this->cur_bytes_ = new_value; } -template <ACE_SYNCH_DECL> void -ACE_Message_Queue<ACE_SYNCH_USE>::message_length (size_t new_value) +template <ACE_SYNCH_DECL, class TIME_POLICY> void +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::message_length (size_t new_value) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::message_length"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::message_length"); ACE_GUARD (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_); this->cur_length_ = new_value; } -template <ACE_SYNCH_DECL> -ACE_Message_Queue<ACE_SYNCH_USE>::ACE_Message_Queue (size_t hwm, +template <ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::ACE_Message_Queue (size_t hwm, size_t lwm, ACE_Notification_Strategy *ns) - : not_empty_cond_ (lock_) - , not_full_cond_ (lock_) + : not_empty_cond_ (lock_, ACE_Condition_Attributes_T<TIME_POLICY> ()) + , not_full_cond_ (lock_, ACE_Condition_Attributes_T<TIME_POLICY> ()) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::ACE_Message_Queue"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::ACE_Message_Queue"); if (this->open (hwm, lwm, ns) == -1) ACE_ERROR ((LM_ERROR, @@ -1048,10 +1077,10 @@ ACE_Message_Queue<ACE_SYNCH_USE>::ACE_Message_Queue (size_t hwm, #endif /* ACE_HAS_MONITOR_POINTS==1 */ } -template <ACE_SYNCH_DECL> -ACE_Message_Queue<ACE_SYNCH_USE>::~ACE_Message_Queue (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::~ACE_Message_Queue (void) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::~ACE_Message_Queue"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::~ACE_Message_Queue"); if (this->head_ != 0 && this->close () == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("close"))); @@ -1062,8 +1091,8 @@ ACE_Message_Queue<ACE_SYNCH_USE>::~ACE_Message_Queue (void) #endif /* ACE_HAS_MONITOR_POINTS==1 */ } -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::flush_i (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::flush_i (void) { int number_flushed = 0; @@ -1105,12 +1134,12 @@ ACE_Message_Queue<ACE_SYNCH_USE>::flush_i (void) // once for the same queue, we're in bigger trouble than just // concurrency control! -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::open (size_t hwm, +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::open (size_t hwm, size_t lwm, ACE_Notification_Strategy *ns) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::open"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::open"); this->high_water_mark_ = hwm; this->low_water_mark_ = lwm; this->state_ = ACE_Message_Queue_Base::ACTIVATED; @@ -1126,10 +1155,10 @@ ACE_Message_Queue<ACE_SYNCH_USE>::open (size_t hwm, // Implementation of the public deactivate() method // (assumes locks are held). -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::deactivate_i (int pulse) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::deactivate_i (int pulse) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::deactivate_i"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::deactivate_i"); int const previous_state = this->state_; if (previous_state != ACE_Message_Queue_Base::DEACTIVATED) @@ -1147,19 +1176,19 @@ ACE_Message_Queue<ACE_SYNCH_USE>::deactivate_i (int pulse) return previous_state; } -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::activate_i (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::activate_i (void) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::activate_i"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::activate_i"); int const previous_state = this->state_; this->state_ = ACE_Message_Queue_Base::ACTIVATED; return previous_state; } -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::flush (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::flush (void) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::flush"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::flush"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); // Free up the remaining messages on the queue. @@ -1168,10 +1197,10 @@ ACE_Message_Queue<ACE_SYNCH_USE>::flush (void) // Clean up the queue if we have not already done so! -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::close (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::close (void) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::close"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::close"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); // There's no need to check the return value of deactivate_i() since @@ -1182,16 +1211,16 @@ ACE_Message_Queue<ACE_SYNCH_USE>::close (void) return this->flush_i (); } -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::signal_enqueue_waiters (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::signal_enqueue_waiters (void) { if (this->not_full_cond_.signal () != 0) return -1; return 0; } -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::signal_dequeue_waiters (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::signal_dequeue_waiters (void) { // Tell any blocked threads that the queue has a new item! if (this->not_empty_cond_.signal () != 0) @@ -1202,10 +1231,10 @@ ACE_Message_Queue<ACE_SYNCH_USE>::signal_dequeue_waiters (void) // Actually put the node at the end (no locking so must be called with // locks held). -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_tail_i (ACE_Message_Block *new_item) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::enqueue_tail_i (ACE_Message_Block *new_item) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_tail_i"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::enqueue_tail_i"); if (new_item == 0) return -1; @@ -1253,10 +1282,10 @@ ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_tail_i (ACE_Message_Block *new_item) // Actually put the node(s) at the head (no locking) -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_head_i (ACE_Message_Block *new_item) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::enqueue_head_i (ACE_Message_Block *new_item) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_head_i"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::enqueue_head_i"); if (new_item == 0) return -1; @@ -1298,10 +1327,10 @@ ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_head_i (ACE_Message_Block *new_item) // Actually put the node at its proper position relative to its // priority. -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_i (ACE_Message_Block *new_item) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::enqueue_i (ACE_Message_Block *new_item) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_i"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::enqueue_i"); if (new_item == 0) return -1; @@ -1369,11 +1398,11 @@ ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_i (ACE_Message_Block *new_item) // Actually put the node at its proper position relative to its // deadline time. -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_deadline_i (ACE_Message_Block *new_item) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::enqueue_deadline_i (ACE_Message_Block *new_item) { #if defined (ACE_HAS_TIMED_MESSAGE_BLOCKS) - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_deadline_i"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::enqueue_deadline_i"); if (new_item == 0) return -1; @@ -1440,14 +1469,14 @@ ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_deadline_i (ACE_Message_Block *new_ite // called with locks held). This method assumes that the queue has at // least one item in it when it is called. -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_head_i (ACE_Message_Block *&first_item) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::dequeue_head_i (ACE_Message_Block *&first_item) { if (this->head_ ==0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Attempting to dequeue from empty queue")), -1); - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_head_i"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::dequeue_head_i"); first_item = this->head_; this->head_ = this->head_->next (); @@ -1491,10 +1520,10 @@ ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_head_i (ACE_Message_Block *&first_item // method assumes that the queue has at least one item in it when it // is called. -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_prio_i (ACE_Message_Block *&dequeued) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::dequeue_prio_i (ACE_Message_Block *&dequeued) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_prio_i"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::dequeue_prio_i"); if (this->head_ == 0) return -1; @@ -1566,14 +1595,14 @@ ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_prio_i (ACE_Message_Block *&dequeued) // called with locks held). This method assumes that the queue has at // least one item in it when it is called. -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_tail_i (ACE_Message_Block *&dequeued) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::dequeue_tail_i (ACE_Message_Block *&dequeued) { if (this->head_ == 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Attempting to dequeue from empty queue")), -1); - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_tail_i"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::dequeue_tail_i"); dequeued = this->tail_; if (this->tail_->prev () == 0) { @@ -1615,15 +1644,15 @@ ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_tail_i (ACE_Message_Block *&dequeued) // (no locking, so must be called with locks held). This method assumes // that the queue has at least one item in it when it is called. -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_deadline_i (ACE_Message_Block *&dequeued) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::dequeue_deadline_i (ACE_Message_Block *&dequeued) { #if defined (ACE_HAS_TIMED_MESSAGE_BLOCKS) if (this->head_ == 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Attempting to dequeue from empty queue")), -1); - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_deadline_i"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::dequeue_deadline_i"); // Find the last message enqueued with the lowest deadline time ACE_Message_Block* chosen = 0; @@ -1685,11 +1714,11 @@ ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_deadline_i (ACE_Message_Block *&dequeu // Take a look at the first item without removing it. -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::peek_dequeue_head (ACE_Message_Block *&first_item, +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::peek_dequeue_head (ACE_Message_Block *&first_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::peek_dequeue_head"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::peek_dequeue_head"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); if (this->state_ == ACE_Message_Queue_Base::DEACTIVATED) @@ -1706,8 +1735,8 @@ ACE_Message_Queue<ACE_SYNCH_USE>::peek_dequeue_head (ACE_Message_Block *&first_i return ACE_Utils::truncate_cast<int> (this->cur_count_); } -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::wait_not_full_cond (ACE_Time_Value *timeout) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::wait_not_full_cond (ACE_Time_Value *timeout) { int result = 0; @@ -1732,8 +1761,8 @@ ACE_Message_Queue<ACE_SYNCH_USE>::wait_not_full_cond (ACE_Time_Value *timeout) return result; } -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::wait_not_empty_cond (ACE_Time_Value *timeout) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::wait_not_empty_cond (ACE_Time_Value *timeout) { int result = 0; @@ -1761,11 +1790,11 @@ ACE_Message_Queue<ACE_SYNCH_USE>::wait_not_empty_cond (ACE_Time_Value *timeout) // Block indefinitely waiting for an item to arrive, does not ignore // alerts (e.g., signals). -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_head (ACE_Message_Block *new_item, +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::enqueue_head (ACE_Message_Block *new_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_head"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::enqueue_head"); int queue_count = 0; ACE_Notification_Strategy *notifier = 0; { @@ -1799,11 +1828,11 @@ ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_head (ACE_Message_Block *new_item, // accordance with its <msg_priority> (0 is lowest priority). Returns // -1 on failure, else the number of items still on the queue. -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_prio (ACE_Message_Block *new_item, +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::enqueue_prio (ACE_Message_Block *new_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_prio"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::enqueue_prio"); int queue_count = 0; ACE_Notification_Strategy *notifier = 0; { @@ -1837,11 +1866,11 @@ ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_prio (ACE_Message_Block *new_item, // accordance with its <msg_deadline_time>. Returns // -1 on failure, else the number of items still on the queue. -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_deadline (ACE_Message_Block *new_item, +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::enqueue_deadline (ACE_Message_Block *new_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_deadline"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::enqueue_deadline"); int queue_count = 0; ACE_Notification_Strategy *notifier = 0; { @@ -1871,22 +1900,22 @@ ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_deadline (ACE_Message_Block *new_item, return queue_count; } -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::enqueue (ACE_Message_Block *new_item, +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::enqueue (ACE_Message_Block *new_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::enqueue"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::enqueue"); return this->enqueue_prio (new_item, timeout); } // Block indefinitely waiting for an item to arrive, // does not ignore alerts (e.g., signals). -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_tail (ACE_Message_Block *new_item, +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::enqueue_tail (ACE_Message_Block *new_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_tail"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::enqueue_tail"); int queue_count = 0; ACE_Notification_Strategy *notifier = 0; { @@ -1920,11 +1949,11 @@ ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_tail (ACE_Message_Block *new_item, // indefinitely (or until an alert occurs). Otherwise, block for upto // the amount of time specified by timeout. -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_head (ACE_Message_Block *&first_item, +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::dequeue_head (ACE_Message_Block *&first_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_head"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::dequeue_head"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); if (this->state_ == ACE_Message_Queue_Base::DEACTIVATED) @@ -1943,11 +1972,11 @@ ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_head (ACE_Message_Block *&first_item, // indefinitely (or until an alert occurs). Otherwise, block for upto // the amount of time specified by timeout. -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_prio (ACE_Message_Block *&dequeued, +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::dequeue_prio (ACE_Message_Block *&dequeued, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_prio"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::dequeue_prio"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); if (this->state_ == ACE_Message_Queue_Base::DEACTIVATED) @@ -1966,11 +1995,11 @@ ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_prio (ACE_Message_Block *&dequeued, // indefinitely (or until an alert occurs). Otherwise, block for upto // the amount of time specified by timeout. -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_tail (ACE_Message_Block *&dequeued, +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::dequeue_tail (ACE_Message_Block *&dequeued, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_tail"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::dequeue_tail"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); if (this->state_ == ACE_Message_Queue_Base::DEACTIVATED) @@ -1989,11 +2018,11 @@ ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_tail (ACE_Message_Block *&dequeued, // indefinitely (or until an alert occurs). Otherwise, block for upto // the amount of time specified by timeout. -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_deadline (ACE_Message_Block *&dequeued, +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::dequeue_deadline (ACE_Message_Block *&dequeued, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_deadline"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::dequeue_deadline"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); if (this->state_ == ACE_Message_Queue_Base::DEACTIVATED) @@ -2008,10 +2037,10 @@ ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_deadline (ACE_Message_Block *&dequeued return this->dequeue_deadline_i (dequeued); } -template <ACE_SYNCH_DECL> int -ACE_Message_Queue<ACE_SYNCH_USE>::notify (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::notify (void) { - ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::notify"); + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::notify"); // By default, don't do anything. if (this->notification_strategy_ == 0) @@ -2021,12 +2050,12 @@ ACE_Message_Queue<ACE_SYNCH_USE>::notify (void) } // = Initialization and termination methods. -template <ACE_SYNCH_DECL> -ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::ACE_Dynamic_Message_Queue (ACE_Dynamic_Message_Strategy & message_strategy, +template <ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Dynamic_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::ACE_Dynamic_Message_Queue (ACE_Dynamic_Message_Strategy & message_strategy, size_t hwm, size_t lwm, ACE_Notification_Strategy *ns) - : ACE_Message_Queue<ACE_SYNCH_USE> (hwm, lwm, ns), + : ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY> (hwm, lwm, ns), pending_head_ (0), pending_tail_ (0), late_head_ (0), @@ -2042,14 +2071,14 @@ ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::ACE_Dynamic_Message_Queue (ACE_Dynamic // dtor: free message strategy and let base class dtor do the rest. -template <ACE_SYNCH_DECL> -ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::~ACE_Dynamic_Message_Queue (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Dynamic_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::~ACE_Dynamic_Message_Queue (void) { delete &this->message_strategy_; } -template <ACE_SYNCH_DECL> int -ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::remove_messages (ACE_Message_Block *&list_head, +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Dynamic_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::remove_messages (ACE_Message_Block *&list_head, ACE_Message_Block *&list_tail, u_int status_flags) { @@ -2188,11 +2217,11 @@ ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::remove_messages (ACE_Message_Block *&l // messages are returned in priority order, from head to tail, as of // the time this method was called. -template <ACE_SYNCH_DECL> int -ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::dequeue_head (ACE_Message_Block *&first_item, +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Dynamic_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::dequeue_head (ACE_Message_Block *&first_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::dequeue_head"); + ACE_TRACE ("ACE_Dynamic_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::dequeue_head"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); @@ -2228,15 +2257,15 @@ ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::dequeue_head (ACE_Message_Block *&firs // Dequeue and return the <ACE_Message_Block *> at the (logical) head // of the queue. -template <ACE_SYNCH_DECL> void -ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::dump (void) const +template <ACE_SYNCH_DECL, class TIME_POLICY> void +ACE_Dynamic_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::dump (void) const { #if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::dump"); + ACE_TRACE ("ACE_Dynamic_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Message_Queue<ACE_SYNCH_USE> (base class):\n"))); - this->ACE_Message_Queue<ACE_SYNCH_USE>::dump (); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY> (base class):\n"))); + this->ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::dump (); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("pending_head_ = %u\n") @@ -2260,10 +2289,10 @@ ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::dump (void) const } // dump the state of the queue -template <ACE_SYNCH_DECL> int -ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::enqueue_i (ACE_Message_Block *new_item) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Dynamic_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::enqueue_i (ACE_Message_Block *new_item) { - ACE_TRACE ("ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::enqueue_i"); + ACE_TRACE ("ACE_Dynamic_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::enqueue_i"); if (new_item == 0) { @@ -2415,8 +2444,8 @@ ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::enqueue_i (ACE_Message_Block *new_item // Message Queue constructor to update the priorities of all enqueued // messages. -template <ACE_SYNCH_DECL> int -ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::sublist_enqueue_i (ACE_Message_Block *new_item, +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Dynamic_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::sublist_enqueue_i (ACE_Message_Block *new_item, const ACE_Time_Value ¤t_time, ACE_Message_Block *&sublist_head, ACE_Message_Block *&sublist_tail, @@ -2484,10 +2513,10 @@ ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::sublist_enqueue_i (ACE_Message_Block * // Enqueue a message in priority order within a given priority status // sublist. -template <ACE_SYNCH_DECL> int -ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::dequeue_head_i (ACE_Message_Block *&first_item) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Dynamic_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::dequeue_head_i (ACE_Message_Block *&first_item) { - ACE_TRACE ("ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::dequeue_head_i"); + ACE_TRACE ("ACE_Dynamic_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::dequeue_head_i"); int result = 0; int last_in_subqueue = 0; @@ -2615,8 +2644,8 @@ ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::dequeue_head_i (ACE_Message_Block *&fi // is empty from the beyond late portion, or if that is empty just // sets the passed pointer to zero and returns -1. -template <ACE_SYNCH_DECL> int -ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::refresh_queue (const ACE_Time_Value ¤t_time) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Dynamic_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::refresh_queue (const ACE_Time_Value ¤t_time) { int result; @@ -2631,8 +2660,8 @@ ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::refresh_queue (const ACE_Time_Value &c // Refresh the queue using the strategy specific priority status // function. -template <ACE_SYNCH_DECL> int -ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::refresh_pending_queue (const ACE_Time_Value ¤t_time) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Dynamic_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::refresh_pending_queue (const ACE_Time_Value ¤t_time) { ACE_Dynamic_Message_Strategy::Priority_Status current_status; @@ -2754,8 +2783,8 @@ ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::refresh_pending_queue (const ACE_Time_ // Refresh the pending queue using the strategy specific priority // status function. -template <ACE_SYNCH_DECL> int -ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::refresh_late_queue (const ACE_Time_Value ¤t_time) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Dynamic_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::refresh_late_queue (const ACE_Time_Value ¤t_time) { ACE_Dynamic_Message_Strategy::Priority_Status current_status; @@ -2839,22 +2868,22 @@ ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::refresh_late_queue (const ACE_Time_Val // Refresh the late queue using the strategy specific priority status // function. -template <ACE_SYNCH_DECL> int -ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::peek_dequeue_head (ACE_Message_Block *&first_item, +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Dynamic_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::peek_dequeue_head (ACE_Message_Block *&first_item, ACE_Time_Value *timeout) { - return ACE_Message_Queue<ACE_SYNCH_USE>::peek_dequeue_head (first_item, + return ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::peek_dequeue_head (first_item, timeout); } // Private method to hide public base class method: just calls base // class method. -template <ACE_SYNCH_DECL> int -ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::enqueue_tail (ACE_Message_Block *new_item, +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Dynamic_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::enqueue_tail (ACE_Message_Block *new_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::enqueue_tail"); + ACE_TRACE ("ACE_Dynamic_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::enqueue_tail"); return this->enqueue_prio (new_item, timeout); } @@ -2863,11 +2892,11 @@ ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::enqueue_tail (ACE_Message_Block *new_i // where it was placed after the queue is refreshed prior to the next // enqueue or dequeue operation. -template <ACE_SYNCH_DECL> int -ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::enqueue_head (ACE_Message_Block *new_item, +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Dynamic_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::enqueue_head (ACE_Message_Block *new_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::enqueue_head"); + ACE_TRACE ("ACE_Dynamic_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::enqueue_head"); return this->enqueue_prio (new_item, timeout); } @@ -2876,25 +2905,26 @@ ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::enqueue_head (ACE_Message_Block *new_i // where it was placed after the queue is refreshed prior to the next // enqueue or dequeue operation. -template <ACE_SYNCH_DECL> -ACE_Message_Queue<ACE_SYNCH_USE> * -ACE_Message_Queue_Factory<ACE_SYNCH_USE>::create_static_message_queue (size_t hwm, +template <ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY> * +ACE_Message_Queue_Factory<ACE_SYNCH_USE, TIME_POLICY>::create_static_message_queue (size_t hwm, size_t lwm, ACE_Notification_Strategy *ns) { - ACE_Message_Queue<ACE_SYNCH_USE> *tmp = 0; + typedef ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY> QUEUE_TYPE; + QUEUE_TYPE *tmp = 0; ACE_NEW_RETURN (tmp, - ACE_Message_Queue<ACE_SYNCH_USE> (hwm, lwm, ns), + QUEUE_TYPE (hwm, lwm, ns), 0); return tmp; } // Factory method for a statically prioritized ACE_Message_Queue. -template <ACE_SYNCH_DECL> -ACE_Dynamic_Message_Queue<ACE_SYNCH_USE> * -ACE_Message_Queue_Factory<ACE_SYNCH_USE>::create_deadline_message_queue (size_t hwm, +template <ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Dynamic_Message_Queue<ACE_SYNCH_USE, TIME_POLICY> * +ACE_Message_Queue_Factory<ACE_SYNCH_USE, TIME_POLICY>::create_deadline_message_queue (size_t hwm, size_t lwm, ACE_Notification_Strategy *ns, u_long static_bit_field_mask, @@ -2911,9 +2941,10 @@ ACE_Message_Queue_Factory<ACE_SYNCH_USE>::create_deadline_message_queue (size_t dynamic_priority_offset), 0); - ACE_Dynamic_Message_Queue<ACE_SYNCH_USE> *tmp = 0; + typedef ACE_Dynamic_Message_Queue<ACE_SYNCH_USE, TIME_POLICY> QUEUE_TYPE; + QUEUE_TYPE *tmp = 0; ACE_NEW_RETURN (tmp, - ACE_Dynamic_Message_Queue<ACE_SYNCH_USE> (*adms, hwm, lwm, ns), + QUEUE_TYPE (*adms, hwm, lwm, ns), 0); return tmp; } @@ -2921,9 +2952,9 @@ ACE_Message_Queue_Factory<ACE_SYNCH_USE>::create_deadline_message_queue (size_t // Factory method for a dynamically prioritized (by time to deadline) // ACE_Dynamic_Message_Queue. -template <ACE_SYNCH_DECL> -ACE_Dynamic_Message_Queue<ACE_SYNCH_USE> * -ACE_Message_Queue_Factory<ACE_SYNCH_USE>::create_laxity_message_queue (size_t hwm, +template <ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Dynamic_Message_Queue<ACE_SYNCH_USE, TIME_POLICY> * +ACE_Message_Queue_Factory<ACE_SYNCH_USE, TIME_POLICY>::create_laxity_message_queue (size_t hwm, size_t lwm, ACE_Notification_Strategy *ns, u_long static_bit_field_mask, @@ -2940,9 +2971,10 @@ ACE_Message_Queue_Factory<ACE_SYNCH_USE>::create_laxity_message_queue (size_t hw dynamic_priority_offset), 0); - ACE_Dynamic_Message_Queue<ACE_SYNCH_USE> *tmp = 0; + typedef ACE_Dynamic_Message_Queue<ACE_SYNCH_USE, TIME_POLICY> QUEUE_TYPE; + QUEUE_TYPE *tmp = 0; ACE_NEW_RETURN (tmp, - ACE_Dynamic_Message_Queue<ACE_SYNCH_USE> (*alms, hwm, lwm, ns), + QUEUE_TYPE (*alms, hwm, lwm, ns), 0); return tmp; } @@ -2953,9 +2985,9 @@ ACE_Message_Queue_Factory<ACE_SYNCH_USE>::create_laxity_message_queue (size_t hw #if defined (ACE_VXWORKS) // factory method for a wrapped VxWorks message queue -template <ACE_SYNCH_DECL> +template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_Message_Queue_Vx * -ACE_Message_Queue_Factory<ACE_SYNCH_USE>::create_Vx_message_queue (size_t max_messages, +ACE_Message_Queue_Factory<ACE_SYNCH_USE, TIME_POLICY>::create_Vx_message_queue (size_t max_messages, size_t max_message_length, ACE_Notification_Strategy *ns) { @@ -2970,9 +3002,9 @@ ACE_Message_Queue_Factory<ACE_SYNCH_USE>::create_Vx_message_queue (size_t max_me #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) -template <ACE_SYNCH_DECL> +template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_Message_Queue_NT * -ACE_Message_Queue_Factory<ACE_SYNCH_USE>::create_NT_message_queue (size_t max_threads) +ACE_Message_Queue_Factory<ACE_SYNCH_USE, TIME_POLICY>::create_NT_message_queue (size_t max_threads) { ACE_Message_Queue_NT *tmp = 0; diff --git a/ACE/ace/Message_Queue_T.h b/ACE/ace/Message_Queue_T.h index 5d9dd4921a2..8e244f7a072 100644 --- a/ACE/ace/Message_Queue_T.h +++ b/ACE/ace/Message_Queue_T.h @@ -19,6 +19,8 @@ #include "ace/Dynamic_Message_Strategy.h" #include "ace/Synch_Traits.h" #include "ace/Guard_T.h" +#include "ace/Time_Policy.h" +#include "ace/Time_Value_T.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once @@ -61,17 +63,17 @@ namespace ACE * All data passing through ACE_Message_Queue is in the form of * ACE_Message_Block objects. @sa ACE_Message_Block. */ -template <ACE_SYNCH_DECL> +template <ACE_SYNCH_DECL, class TIME_POLICY = ACE_System_Time_Policy> class ACE_Message_Queue : public ACE_Message_Queue_Base { public: - friend class ACE_Message_Queue_Iterator<ACE_SYNCH_USE>; - friend class ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_USE>; + friend class ACE_Message_Queue_Iterator<ACE_SYNCH_USE, TIME_POLICY>; + friend class ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_USE, TIME_POLICY>; // = Traits - typedef ACE_Message_Queue_Iterator<ACE_SYNCH_USE> + typedef ACE_Message_Queue_Iterator<ACE_SYNCH_USE, TIME_POLICY> ITERATOR; - typedef ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_USE> + typedef ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_USE, TIME_POLICY> REVERSE_ITERATOR; /** @@ -482,6 +484,14 @@ public: /// Returns a reference to the lock used by the ACE_Message_Queue. virtual ACE_SYNCH_MUTEX_T &lock (void); + /// Get the current time of day according to the queue's TIME_POLICY. + /// Allows users to initialize timeout values using correct time policy. + ACE_Time_Value_T<TIME_POLICY> gettimeofday (void) const; + + /// Allows applications to control how the timer queue gets the time + /// of day. + void set_time_policy (TIME_POLICY const & time_policy); + /// Dump the state of an object. virtual void dump (void) const; @@ -602,6 +612,9 @@ protected: /// Used to make threads sleep until the queue is no longer full. ACE_SYNCH_CONDITION_T not_full_cond_; + /// The policy to return the current time of day + TIME_POLICY time_policy_; + /// Sends the size of the queue whenever it changes. #if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1) ACE::Monitor_Control::Size_Monitor *monitor_; @@ -623,12 +636,12 @@ typedef ACE_Message_Queue<ACE_SYNCH> ACE_DEFAULT_MESSAGE_QUEUE_TYPE; * * @brief Iterator for the ACE_Message_Queue. */ -template <ACE_SYNCH_DECL> +template <ACE_SYNCH_DECL, class TIME_POLICY = ACE_System_Time_Policy> class ACE_Message_Queue_Iterator { public: // = Initialization method. - ACE_Message_Queue_Iterator (ACE_Message_Queue <ACE_SYNCH_USE> &queue); + ACE_Message_Queue_Iterator (ACE_Message_Queue <ACE_SYNCH_USE, TIME_POLICY> &queue); // = Iteration methods. /// Pass back the @a entry that hasn't been seen in the queue. @@ -650,7 +663,7 @@ public: private: /// Message_Queue we are iterating over. - ACE_Message_Queue <ACE_SYNCH_USE> &queue_; + ACE_Message_Queue <ACE_SYNCH_USE, TIME_POLICY> &queue_; /// Keeps track of how far we've advanced... ACE_Message_Block *curr_; @@ -661,12 +674,12 @@ private: * * @brief Reverse Iterator for the ACE_Message_Queue. */ -template <ACE_SYNCH_DECL> +template <ACE_SYNCH_DECL, class TIME_POLICY = ACE_System_Time_Policy> class ACE_Message_Queue_Reverse_Iterator { public: // = Initialization method. - ACE_Message_Queue_Reverse_Iterator (ACE_Message_Queue <ACE_SYNCH_USE> &queue); + ACE_Message_Queue_Reverse_Iterator (ACE_Message_Queue <ACE_SYNCH_USE, TIME_POLICY> &queue); // = Iteration methods. /// Pass back the @a entry that hasn't been seen in the queue. @@ -688,7 +701,7 @@ public: private: /// Message_Queue we are iterating over. - ACE_Message_Queue <ACE_SYNCH_USE> &queue_; + ACE_Message_Queue <ACE_SYNCH_USE, TIME_POLICY> &queue_; /// Keeps track of how far we've advanced... ACE_Message_Block *curr_; @@ -761,8 +774,8 @@ private: * ensure the correct semantics, but that is not a * very stable or portable approach (discouraged). */ -template <ACE_SYNCH_DECL> -class ACE_Dynamic_Message_Queue : public ACE_Message_Queue<ACE_SYNCH_USE> +template <ACE_SYNCH_DECL, class TIME_POLICY = ACE_System_Time_Policy> +class ACE_Dynamic_Message_Queue : public ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY> { public: // = Initialization and termination methods. @@ -883,8 +896,8 @@ protected: private: // = Disallow public access to these operations. - ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Dynamic_Message_Queue<ACE_SYNCH_USE> &)) - ACE_UNIMPLEMENTED_FUNC (ACE_Dynamic_Message_Queue (const ACE_Dynamic_Message_Queue<ACE_SYNCH_USE> &)) + ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Dynamic_Message_Queue<ACE_SYNCH_USE, TIME_POLICY> &)) + ACE_UNIMPLEMENTED_FUNC (ACE_Dynamic_Message_Queue (const ACE_Dynamic_Message_Queue<ACE_SYNCH_USE, TIME_POLICY> &)) // provide definitions for these (just call base class method), // but make them private so they're not accessible outside the class @@ -909,18 +922,18 @@ private: * any of these factory methods is only responsible for * ensuring destruction of the message queue itself. */ -template <ACE_SYNCH_DECL> +template <ACE_SYNCH_DECL, class TIME_POLICY = ACE_System_Time_Policy> class ACE_Message_Queue_Factory { public: /// Factory method for a statically prioritized ACE_Message_Queue - static ACE_Message_Queue<ACE_SYNCH_USE> * + static ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY> * create_static_message_queue (size_t hwm = ACE_Message_Queue_Base::DEFAULT_HWM, size_t lwm = ACE_Message_Queue_Base::DEFAULT_LWM, ACE_Notification_Strategy * = 0); /// Factory method for a dynamically prioritized (by time to deadline) ACE_Dynamic_Message_Queue - static ACE_Dynamic_Message_Queue<ACE_SYNCH_USE> * + static ACE_Dynamic_Message_Queue<ACE_SYNCH_USE, TIME_POLICY> * create_deadline_message_queue (size_t hwm = ACE_Message_Queue_Base::DEFAULT_HWM, size_t lwm = ACE_Message_Queue_Base::DEFAULT_LWM, ACE_Notification_Strategy * = 0, @@ -930,7 +943,7 @@ public: u_long dynamic_priority_offset = 0x200000UL); // 2^(22-1) /// Factory method for a dynamically prioritized (by laxity) ACE_Dynamic_Message_Queue - static ACE_Dynamic_Message_Queue<ACE_SYNCH_USE> * + static ACE_Dynamic_Message_Queue<ACE_SYNCH_USE, TIME_POLICY> * create_laxity_message_queue (size_t hwm = ACE_Message_Queue_Base::DEFAULT_HWM, size_t lwm = ACE_Message_Queue_Base::DEFAULT_LWM, ACE_Notification_Strategy * = 0, @@ -959,8 +972,8 @@ public: }; // Forward decls. -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> class ACE_Message_Queue_Ex_Iterator; -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> class ACE_Message_Queue_Ex_Reverse_Iterator; +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> class ACE_Message_Queue_Ex_Iterator; +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> class ACE_Message_Queue_Ex_Reverse_Iterator; /** * @class ACE_Message_Queue_Ex @@ -979,7 +992,7 @@ template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> class ACE_Message_Queue_Ex_Rev * -# ACE_MT_SYNCH: all operations are thread-safe * -# ACE_NULL_SYNCH: no synchronization and no locking overhead */ -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY = ACE_System_Time_Policy> class ACE_Message_Queue_Ex { public: @@ -990,13 +1003,13 @@ public: DEFAULT_PRIORITY = 0 }; - friend class ACE_Message_Queue_Ex_Iterator <ACE_MESSAGE_TYPE, ACE_SYNCH_USE>; - friend class ACE_Message_Queue_Ex_Reverse_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>; + friend class ACE_Message_Queue_Ex_Iterator <ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>; + friend class ACE_Message_Queue_Ex_Reverse_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>; // = Traits - typedef ACE_Message_Queue_Ex_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE> + typedef ACE_Message_Queue_Ex_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY> ITERATOR; - typedef ACE_Message_Queue_Ex_Reverse_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE> + typedef ACE_Message_Queue_Ex_Reverse_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY> REVERSE_ITERATOR; /** @@ -1365,6 +1378,14 @@ public: /// Returns a reference to the lock used by the ACE_Message_Queue_Ex. virtual ACE_SYNCH_MUTEX_T &lock (void); + /// Get the current time of day according to the queue's TIME_POLICY. + /// Allows users to initialize timeout + ACE_Time_Value_T<TIME_POLICY> gettimeofday (); + + /// Allows applications to control how the timer queue gets the time + /// of day. + void set_time_policy (TIME_POLICY const & time_policy); + /// Dump the state of an object. virtual void dump (void) const; @@ -1373,7 +1394,7 @@ public: protected: /// Implement this via an ACE_Message_Queue. - ACE_Message_Queue<ACE_SYNCH_USE> queue_; + ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY> queue_; }; /** @@ -1381,12 +1402,12 @@ protected: * * @brief Iterator for the ACE_Message_Queue_Ex. */ -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY = ACE_System_Time_Policy> class ACE_Message_Queue_Ex_Iterator { public: // = Initialization method. - ACE_Message_Queue_Ex_Iterator (ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE> & queue); + ACE_Message_Queue_Ex_Iterator (ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY> & queue); // = Iteration methods. /// Pass back the @a entry that hasn't been seen in the queue. @@ -1408,7 +1429,7 @@ public: private: /// Implement this via the ACE_Message_Queue_Iterator - ACE_Message_Queue_Iterator<ACE_SYNCH_USE> iter_; + ACE_Message_Queue_Iterator<ACE_SYNCH_USE, TIME_POLICY> iter_; }; /** @@ -1416,12 +1437,12 @@ private: * * @brief Reverse iterator for the ACE_Message_Queue_Ex. */ -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY = ACE_System_Time_Policy> class ACE_Message_Queue_Ex_Reverse_Iterator { public: // = Initialization method. - ACE_Message_Queue_Ex_Reverse_Iterator (ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE> & queue); + ACE_Message_Queue_Ex_Reverse_Iterator (ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY> & queue); // = Iteration methods. /// Pass back the @a entry that hasn't been seen in the queue. @@ -1443,7 +1464,7 @@ public: private: /// Implement this via the ACE_Message_Queue_Reverse_Iterator - ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_USE> iter_; + ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_USE, TIME_POLICY> iter_; }; /** @@ -1464,8 +1485,8 @@ private: * ACE_Message_Queue_Ex_N uses this method to run through * all the incoming messages and enqueue them in one call. */ -template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> -class ACE_Message_Queue_Ex_N : public ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE> +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY = ACE_System_Time_Policy> +class ACE_Message_Queue_Ex_N : public ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY> { public: // = Initialization and termination methods. diff --git a/ACE/ace/Module.cpp b/ACE/ace/Module.cpp index 49cdcf98cc2..6799d335cc0 100644 --- a/ACE/ace/Module.cpp +++ b/ACE/ace/Module.cpp @@ -19,19 +19,19 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_ALLOC_HOOK_DEFINE(ACE_Module) -template <ACE_SYNCH_DECL> void -ACE_Module<ACE_SYNCH_USE>::dump (void) const +template <ACE_SYNCH_DECL, class TIME_POLICY> void +ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::dump (void) const { #if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::dump"); + ACE_TRACE ("ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::dump"); #endif /* ACE_HAS_DUMP */ } -template <ACE_SYNCH_DECL> void -ACE_Module<ACE_SYNCH_USE>::writer (ACE_Task<ACE_SYNCH_USE> *q, +template <ACE_SYNCH_DECL, class TIME_POLICY> void +ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::writer (ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *q, int flags /* = M_DELETE_WRITER */) { - ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::writer"); + ACE_TRACE ("ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::writer"); // Close and maybe delete old writer this->close_i (1, flags); @@ -49,11 +49,11 @@ ACE_Module<ACE_SYNCH_USE>::writer (ACE_Task<ACE_SYNCH_USE> *q, ACE_SET_BITS (flags_, (flags & M_DELETE_WRITER)); } -template <ACE_SYNCH_DECL> void -ACE_Module<ACE_SYNCH_USE>::reader (ACE_Task<ACE_SYNCH_USE> *q, +template <ACE_SYNCH_DECL, class TIME_POLICY> void +ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::reader (ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *q, int flags /* = M_DELETE_READER */) { - ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::reader"); + ACE_TRACE ("ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::reader"); // Close and maybe delete old writer this->close_i (0, flags); @@ -73,23 +73,23 @@ ACE_Module<ACE_SYNCH_USE>::reader (ACE_Task<ACE_SYNCH_USE> *q, // Link this ACE_Module on top of ACE_Module M. -template <ACE_SYNCH_DECL> void -ACE_Module<ACE_SYNCH_USE>::link (ACE_Module<ACE_SYNCH_USE> *m) +template <ACE_SYNCH_DECL, class TIME_POLICY> void +ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::link (ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *m) { - ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::link"); + ACE_TRACE ("ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::link"); this->next (m); this->writer ()->next (m->writer ()); m->reader ()->next (this->reader ()); } -template <ACE_SYNCH_DECL> int -ACE_Module<ACE_SYNCH_USE>::open (const ACE_TCHAR *module_name, - ACE_Task<ACE_SYNCH_USE> *writer_q, - ACE_Task<ACE_SYNCH_USE> *reader_q, +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::open (const ACE_TCHAR *module_name, + ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *writer_q, + ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *reader_q, void *arg, int flags /* = M_DELETE */) { - ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::open"); + ACE_TRACE ("ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::open"); this->name (module_name); this->arg_ = arg; @@ -102,16 +102,18 @@ ACE_Module<ACE_SYNCH_USE>::open (const ACE_TCHAR *module_name, if (writer_q == 0) { + typedef ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY> TASK_TYPE; ACE_NEW_RETURN (writer_q, - ACE_Thru_Task<ACE_SYNCH_USE>, + TASK_TYPE, -1); ACE_SET_BITS (flags, M_DELETE_WRITER); } if (reader_q == 0) { + typedef ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY> TASK_TYPE; ACE_NEW_RETURN (reader_q, - ACE_Thru_Task<ACE_SYNCH_USE>, + TASK_TYPE, -1); ACE_SET_BITS (flags, M_DELETE_READER); } @@ -144,10 +146,10 @@ ACE_Module<ACE_SYNCH_USE>::open (const ACE_TCHAR *module_name, // Set and get pointer to sibling ACE_Task in ACE_Module. -template <ACE_SYNCH_DECL> ACE_Task<ACE_SYNCH_USE> * -ACE_Module<ACE_SYNCH_USE>::sibling (ACE_Task<ACE_SYNCH_USE> *orig) +template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_Task<ACE_SYNCH_USE, TIME_POLICY> * +ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::sibling (ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *orig) { - ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::sibling"); + ACE_TRACE ("ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::sibling"); if (this->q_pair_[0] == orig) return this->q_pair_[1]; else if (this->q_pair_[1] == orig) @@ -156,38 +158,38 @@ ACE_Module<ACE_SYNCH_USE>::sibling (ACE_Task<ACE_SYNCH_USE> *orig) return 0; } -template <ACE_SYNCH_DECL> -ACE_Module<ACE_SYNCH_USE>::ACE_Module (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::ACE_Module (void) : next_ (0) , arg_ (0) , flags_ (M_FLAGS_NOT_SET) { - ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::ACE_Module"); + ACE_TRACE ("ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::ACE_Module"); this->name (ACE_TEXT ("<unknown>")); // Do nothing... this->q_pair_[0] = 0; this->q_pair_[1] = 0; } -template <ACE_SYNCH_DECL> -ACE_Module<ACE_SYNCH_USE>::~ACE_Module (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::~ACE_Module (void) { - ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::~ACE_Module"); + ACE_TRACE ("ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::~ACE_Module"); // Only close down if we haven't already done so. if (this->reader () || this->writer ()) this->close (); } -template <ACE_SYNCH_DECL> -ACE_Module<ACE_SYNCH_USE>::ACE_Module (const ACE_TCHAR *module_name, - ACE_Task<ACE_SYNCH_USE> *writer_q, - ACE_Task<ACE_SYNCH_USE> *reader_q, +template <ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::ACE_Module (const ACE_TCHAR *module_name, + ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *writer_q, + ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *reader_q, void *args, int flags /* = M_DELETE */) : flags_ (M_FLAGS_NOT_SET) { - ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::ACE_Module"); + ACE_TRACE ("ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::ACE_Module"); this->q_pair_[0] = 0; this->q_pair_[1] = 0; @@ -198,10 +200,10 @@ ACE_Module<ACE_SYNCH_USE>::ACE_Module (const ACE_TCHAR *module_name, ACE_TEXT ("ACE_Module"))); } -template <ACE_SYNCH_DECL> int -ACE_Module<ACE_SYNCH_USE>::close (int flags /* = M_DELETE_NONE */) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::close (int flags /* = M_DELETE_NONE */) { - ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::close"); + ACE_TRACE ("ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::close"); int result = 0; @@ -219,18 +221,18 @@ ACE_Module<ACE_SYNCH_USE>::close (int flags /* = M_DELETE_NONE */) return result; } -template <ACE_SYNCH_DECL> int -ACE_Module<ACE_SYNCH_USE>::close_i (int which, +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::close_i (int which, int flags) { - ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::close_i"); + ACE_TRACE ("ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::close_i"); if (this->q_pair_[which] == 0) return 0; // Copy task pointer to prevent problems when ACE_Task::close // changes the task pointer - ACE_Task<ACE_SYNCH_USE> *task = this->q_pair_[which]; + ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *task = this->q_pair_[which]; // Change so that close doesn't get called again from the task base. diff --git a/ACE/ace/Module.h b/ACE/ace/Module.h index 3e3ff89b86e..66e76c2f5d4 100644 --- a/ACE/ace/Module.h +++ b/ACE/ace/Module.h @@ -74,7 +74,7 @@ public: * general, you shouldn't subclass from this class, but instead * subclass from the ACE_Task. */ -template <ACE_SYNCH_DECL> +template <ACE_SYNCH_DECL, class TIME_POLICY = ACE_System_Time_Policy> class ACE_Module : public ACE_Module_Base { public: @@ -88,8 +88,8 @@ public: /// Create an initialized module with @a module_name as its identity /// and @a reader and @a writer as its tasks. ACE_Module (const ACE_TCHAR *module_name, - ACE_Task<ACE_SYNCH_USE> *writer = 0, - ACE_Task<ACE_SYNCH_USE> *reader = 0, + ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *writer = 0, + ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *reader = 0, void *args = 0, int flags = M_DELETE); @@ -101,8 +101,8 @@ public: * <ACE_Task::module_closed>. */ int open (const ACE_TCHAR *module_name, - ACE_Task<ACE_SYNCH_USE> *writer = 0, - ACE_Task<ACE_SYNCH_USE> *reader = 0, + ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *writer = 0, + ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *reader = 0, void *a = 0, int flags = M_DELETE); @@ -117,7 +117,7 @@ public: // = ACE_Task manipulation routines /// Get the writer task. - ACE_Task<ACE_SYNCH_USE> *writer (void); + ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *writer (void); /** * Set the writer task. @a flags can be used to indicate that the @@ -126,10 +126,10 @@ public: * also be deleted, depending on the old flags_ value. Should not * be called from within <ACE_Task::module_closed>. */ - void writer (ACE_Task<ACE_SYNCH_USE> *q, int flags = M_DELETE_WRITER); + void writer (ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *q, int flags = M_DELETE_WRITER); /// Get the reader task. - ACE_Task<ACE_SYNCH_USE> *reader (void); + ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *reader (void); /** * Set the reader task. @a flags can be used to indicate that the @@ -138,10 +138,10 @@ public: * also be deleted, depending on the old flags_ value. Should not * be called from within <ACE_Task::module_closed>. */ - void reader (ACE_Task<ACE_SYNCH_USE> *q, int flags = M_DELETE_READER); + void reader (ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *q, int flags = M_DELETE_READER); /// Set and get pointer to sibling ACE_Task in an ACE_Module - ACE_Task<ACE_SYNCH_USE> *sibling (ACE_Task<ACE_SYNCH_USE> *orig); + ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *sibling (ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *orig); // = Identify the module /// Get the module name. @@ -158,13 +158,13 @@ public: void arg (void *); /// Link to other modules in the ustream stack - void link (ACE_Module<ACE_SYNCH_USE> *m); + void link (ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *m); /// Get the next pointer to the module above in the stream. - ACE_Module<ACE_SYNCH_USE> *next (void); + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *next (void); /// Set the next pointer to the module above in the stream. - void next (ACE_Module<ACE_SYNCH_USE> *m); + void next (ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *m); /// Dump the state of an object. void dump (void) const; @@ -179,13 +179,13 @@ private: /// Pair of Tasks that form the "read-side" and "write-side" of the /// ACE_Module partitioning. - ACE_Task<ACE_SYNCH_USE> *q_pair_[2]; + ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *q_pair_[2]; /// Name of the ACE_Module. ACE_TCHAR name_[MAXPATHLEN + 1]; /// Next ACE_Module in the stack. - ACE_Module<ACE_SYNCH_USE> *next_; + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *next_; /// Argument passed through to the reader and writer task when they /// are opened. diff --git a/ACE/ace/Module.inl b/ACE/ace/Module.inl index 483d436aa69..22bcd6a5468 100644 --- a/ACE/ace/Module.inl +++ b/ACE/ace/Module.inl @@ -6,59 +6,59 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -template <ACE_SYNCH_DECL> ACE_INLINE void * -ACE_Module<ACE_SYNCH_USE>::arg (void) const +template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_INLINE void * +ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::arg (void) const { - ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::arg"); + ACE_TRACE ("ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::arg"); return this->arg_; } -template <ACE_SYNCH_DECL> ACE_INLINE void -ACE_Module<ACE_SYNCH_USE>::arg (void *a) +template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_INLINE void +ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::arg (void *a) { - ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::arg"); + ACE_TRACE ("ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::arg"); this->arg_ = a; } -template <ACE_SYNCH_DECL> ACE_INLINE const ACE_TCHAR * -ACE_Module<ACE_SYNCH_USE>::name (void) const +template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_INLINE const ACE_TCHAR * +ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::name (void) const { - ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::name"); + ACE_TRACE ("ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::name"); return this->name_; } -template <ACE_SYNCH_DECL> ACE_INLINE void -ACE_Module<ACE_SYNCH_USE>::name (const ACE_TCHAR *n) +template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_INLINE void +ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::name (const ACE_TCHAR *n) { - ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::name"); + ACE_TRACE ("ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::name"); ACE_OS::strsncpy (this->name_, n, MAXPATHLEN); } -template <ACE_SYNCH_DECL> ACE_INLINE ACE_Task<ACE_SYNCH_USE> * -ACE_Module<ACE_SYNCH_USE>::writer (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_INLINE ACE_Task<ACE_SYNCH_USE, TIME_POLICY> * +ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::writer (void) { - ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::writer"); + ACE_TRACE ("ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::writer"); return this->q_pair_[1]; } -template <ACE_SYNCH_DECL> ACE_INLINE ACE_Task<ACE_SYNCH_USE> * -ACE_Module<ACE_SYNCH_USE>::reader (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_INLINE ACE_Task<ACE_SYNCH_USE, TIME_POLICY> * +ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::reader (void) { - ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::reader"); + ACE_TRACE ("ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::reader"); return this->q_pair_[0]; } -template <ACE_SYNCH_DECL> ACE_INLINE ACE_Module<ACE_SYNCH_USE> * -ACE_Module<ACE_SYNCH_USE>::next (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_INLINE ACE_Module<ACE_SYNCH_USE, TIME_POLICY> * +ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::next (void) { - ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::next"); + ACE_TRACE ("ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::next"); return this->next_; } -template <ACE_SYNCH_DECL> ACE_INLINE void -ACE_Module<ACE_SYNCH_USE>::next (ACE_Module<ACE_SYNCH_USE> *m) +template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_INLINE void +ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::next (ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *m) { - ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::next"); + ACE_TRACE ("ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::next"); this->next_ = m; } diff --git a/ACE/ace/Monotonic_Time_Policy.cpp b/ACE/ace/Monotonic_Time_Policy.cpp new file mode 100644 index 00000000000..ad359e7d6d1 --- /dev/null +++ b/ACE/ace/Monotonic_Time_Policy.cpp @@ -0,0 +1,7 @@ +// $Id$ + +#include "ace/Monotonic_Time_Policy.h" + +#if !defined(__ACE_INLINE__) +# include "ace/Monotonic_Time_Policy.inl" +#endif /* __ACE_INLINE__ */ diff --git a/ACE/ace/Monotonic_Time_Policy.h b/ACE/ace/Monotonic_Time_Policy.h new file mode 100644 index 00000000000..6e7dbd3cbf7 --- /dev/null +++ b/ACE/ace/Monotonic_Time_Policy.h @@ -0,0 +1,50 @@ +#ifndef ACE_MONOTONIC_TIME_POLICY_H +#define ACE_MONOTONIC_TIME_POLICY_H +// -*- C++ -*- +/** + * @file Monotonic_Time_Policy.h + * + * $Id$ + * + * @author Martin Corino <mcorino@remedy.nl> + */ +#include /**/ "ace/pre.h" + +#include /**/ "ace/config-all.h" + +#include /**/ "ace/Time_Value_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Monotonic_Time_Policy + * + * @brief Implement a monotonic time policy for ACE. + * + * This class implements support for returning monotonic time values + * on platforms that support that. + * If a platform does not support monotonic time the policy returns + * ACE_Time_Value::zero. + */ +class ACE_Export ACE_Monotonic_Time_Policy +{ +public: + /// Return the current time according to this policy + ACE_Time_Value_T<ACE_Monotonic_Time_Policy> operator() () const; + + /// Noop. Just here to satisfy backwards compatibility demands. + void set_gettimeofday (ACE_Time_Value (*gettimeofday)(void)); +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Monotonic_Time_Policy.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* ACE_MONOTONIC_TIME_POLICY_H */ diff --git a/ACE/ace/Monotonic_Time_Policy.inl b/ACE/ace/Monotonic_Time_Policy.inl new file mode 100644 index 00000000000..d0a0b56192e --- /dev/null +++ b/ACE/ace/Monotonic_Time_Policy.inl @@ -0,0 +1,33 @@ +// -*- C++ -*- +// +// $Id$ + +#include "ace/OS_NS_sys_time.h" +#include "ace/High_Res_Timer.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_INLINE ACE_Time_Value_T<ACE_Monotonic_Time_Policy> +ACE_Monotonic_Time_Policy::operator()() const +{ +# if defined (ACE_WIN32) + return ACE_Time_Value_T<ACE_Monotonic_Time_Policy> (ACE_High_Res_Timer::gettimeofday_hr ()); +#elif (defined (_POSIX_MONOTONIC_CLOCK) && !defined (ACE_LACKS_MONOTONIC_TIME)) || defined (ACE_HAS_CLOCK_GETTIME_MONOTONIC) + struct timespec ts; + + if (ACE_OS::clock_gettime (CLOCK_MONOTONIC, + &ts) == 0) + return ACE_Time_Value_T<ACE_Monotonic_Time_Policy>(ts); + else + return ACE_Time_Value_T<ACE_Monotonic_Time_Policy> (ACE_Time_Value::zero); +#else + return ACE_Time_Value_T<ACE_Monotonic_Time_Policy> (ACE_Time_Value::zero); +#endif +} + +ACE_INLINE void +ACE_Monotonic_Time_Policy::set_gettimeofday (ACE_Time_Value (*)(void)) +{ +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Null_Condition.h b/ACE/ace/Null_Condition.h index 31a2cbc9d16..0aec03c3307 100644 --- a/ACE/ace/Null_Condition.h +++ b/ACE/ace/Null_Condition.h @@ -26,24 +26,32 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL +template <class ACE_LOCK> class ACE_Condition; + class ACE_Time_Value; +class ACE_Condition_Attributes; /** - * @class ACE_Null_Condition - * - * @brief Implement a do nothing ACE_Condition variable wrapper, - * i.e., all methods are no ops. This class is necessary since - * some C++ compilers are *very* lame... + * @brief ACE_Condition template specialization written using + * ACE_Null_Mutexes. Implements a do nothing ACE_Condition + * specialization, i.e., all methods are no ops. */ -class ACE_Null_Condition +template <> +class ACE_Condition<ACE_Null_Mutex> { public: - ACE_Null_Condition (const ACE_Null_Mutex &m, - const ACE_TCHAR * = 0, - void * = 0) + ACE_Condition (const ACE_Null_Mutex &m, + const ACE_TCHAR * = 0, + void * = 0) : mutex_ ((ACE_Null_Mutex &) m) {} - ~ACE_Null_Condition (void) {} + ACE_Condition (const ACE_Null_Mutex &m, + const ACE_Condition_Attributes &, + const ACE_TCHAR * = 0, + void * = 0) + : mutex_ ((ACE_Null_Mutex &) m) {} + + ~ACE_Condition (void) {} /// Returns 0. int remove (void) {return 0;} @@ -73,10 +81,12 @@ protected: private: // = Prevent assignment and initialization. - void operator= (const ACE_Null_Condition &); - ACE_Null_Condition (const ACE_Null_Condition &); + void operator= (const ACE_Condition<ACE_Null_Mutex> &); + ACE_Condition (const ACE_Condition<ACE_Null_Mutex> &); }; +typedef ACE_Condition<ACE_Null_Mutex> ACE_Null_Condition; + ACE_END_VERSIONED_NAMESPACE_DECL #include /**/ "ace/post.h" diff --git a/ACE/ace/OS_NS_Thread.cpp b/ACE/ace/OS_NS_Thread.cpp index bce737c1914..9aec524ae8f 100644 --- a/ACE/ace/OS_NS_Thread.cpp +++ b/ACE/ace/OS_NS_Thread.cpp @@ -18,7 +18,7 @@ // This is necessary to work around nasty problems with MVS C++. #include "ace/Auto_Ptr.h" #include "ace/Thread_Mutex.h" -#include "ace/Condition_T.h" +#include "ace/Condition_Thread_Mutex.h" #include "ace/Guard_T.h" extern "C" void @@ -588,7 +588,7 @@ private: static unsigned int reference_count_; static ACE_TSS_Cleanup * instance_; static ACE_Thread_Mutex* mutex_; - static ACE_Thread_Condition<ACE_Thread_Mutex>* condition_; + static ACE_Condition_Thread_Mutex* condition_; private: ACE_TSS_Cleanup * ptr_; @@ -611,7 +611,7 @@ TSS_Cleanup_Instance::TSS_Cleanup_Instance (Purpose purpose) if (mutex_ == 0) { ACE_NEW (mutex_, ACE_Thread_Mutex ()); - ACE_NEW (condition_, ACE_Thread_Condition<ACE_Thread_Mutex> (*mutex_)); + ACE_NEW (condition_, ACE_Condition_Thread_Mutex (*mutex_)); } ACE_GUARD (ACE_Thread_Mutex, m, *mutex_); @@ -711,7 +711,7 @@ TSS_Cleanup_Instance::operator ->() unsigned int TSS_Cleanup_Instance::reference_count_ = 0; ACE_TSS_Cleanup * TSS_Cleanup_Instance::instance_ = 0; ACE_Thread_Mutex* TSS_Cleanup_Instance::mutex_ = 0; -ACE_Thread_Condition<ACE_Thread_Mutex>* TSS_Cleanup_Instance::condition_ = 0; +ACE_Condition_Thread_Mutex* TSS_Cleanup_Instance::condition_ = 0; ACE_TSS_Cleanup::~ACE_TSS_Cleanup (void) { @@ -1411,7 +1411,7 @@ ACE_OS::cond_timedwait (ACE_cond_t *cv, // Note that we must convert between absolute time (which is // passed as a parameter) and relative time (which is what // WaitForSingleObjects() expects). - ACE_Time_Value relative_time (*timeout - ACE_OS::gettimeofday ()); + ACE_Time_Value relative_time = timeout->to_relative_time (); // Watchout for situations where a context switch has caused the // current time to be > the timeout. @@ -1584,7 +1584,7 @@ ACE_OS::cond_timedwait (ACE_cond_t *cv, int msec_timeout = 0; int result = 0; - ACE_Time_Value relative_time (*timeout - ACE_OS::gettimeofday ()); + ACE_Time_Value relative_time = timeout->to_relative_time (); // Watchout for situations where a context switch has caused the // current time to be > the timeout. if (relative_time > ACE_Time_Value::zero) @@ -1613,7 +1613,7 @@ ACE_OS::cond_timedwait (ACE_cond_t *cv, // Note that we must convert between absolute time (which is // passed as a parameter) and relative time (which is what // WaitForSingleObjects() expects). - ACE_Time_Value relative_time (*timeout - ACE_OS::gettimeofday ()); + ACE_Time_Value relative_time = timeout->to_relative_time (); // Watchout for situations where a context switch has caused the // current time to be > the timeout. @@ -2145,7 +2145,7 @@ ACE_OS::mutex_lock (ACE_mutex_t *m, // Note that we must convert between absolute time (which is passed // as a parameter) and relative time (which is what the system call // expects). - ACE_Time_Value relative_time (timeout - ACE_OS::gettimeofday ()); + ACE_Time_Value relative_time = timeout.to_relative_time (); switch (m->type_) { @@ -2179,7 +2179,7 @@ ACE_OS::mutex_lock (ACE_mutex_t *m, // Note that we must convert between absolute time (which is passed // as a parameter) and relative time (which is what the system call // expects). - ACE_Time_Value relative_time (timeout - ACE_OS::gettimeofday ()); + ACE_Time_Value relative_time = timeout.to_relative_time (); int ticks_per_sec = ::sysClkRateGet (); @@ -3016,7 +3016,7 @@ ACE_OS::event_timedwait (ACE_event_t *event, { // Time is given in absolute time, we should use // gettimeofday() to calculate relative time - ACE_Time_Value relative_time (*timeout - ACE_OS::gettimeofday ()); + ACE_Time_Value relative_time = timeout->to_relative_time (); // Watchout for situations where a context switch has caused // the current time to be > the timeout. Thanks to Norbert @@ -3077,7 +3077,7 @@ ACE_OS::event_timedwait (ACE_event_t *event, // cond_timewait() expects absolute time, check // <use_absolute_time> flag. if (use_absolute_time == 0) - absolute_timeout += ACE_OS::gettimeofday (); + absolute_timeout = timeout->to_absolute_time (); while (event->eventdata_->is_signaled_ == 0 && event->eventdata_->auto_event_signaled_ == false) diff --git a/ACE/ace/OS_NS_Thread.h b/ACE/ace/OS_NS_Thread.h index 87f547647e7..e6aaee61bba 100644 --- a/ACE/ace/OS_NS_Thread.h +++ b/ACE/ace/OS_NS_Thread.h @@ -1088,6 +1088,10 @@ namespace ACE_OS { ACE_NAMESPACE_INLINE_FUNCTION int condattr_destroy (ACE_condattr_t &attributes); + ACE_NAMESPACE_INLINE_FUNCTION + int condattr_setclock(ACE_condattr_t &attributes, + clockid_t clock_id); + #if defined (ACE_LACKS_COND_T) extern ACE_Export #else diff --git a/ACE/ace/OS_NS_Thread.inl b/ACE/ace/OS_NS_Thread.inl index b1a7a566d26..9ac4a78b5e7 100644 --- a/ACE/ace/OS_NS_Thread.inl +++ b/ACE/ace/OS_NS_Thread.inl @@ -183,6 +183,32 @@ ACE_OS::condattr_init (ACE_condattr_t &attributes, int type) # endif /* ACE_HAS_THREADS */ } +ACE_INLINE int +ACE_OS::condattr_setclock (ACE_condattr_t &attributes, clockid_t clock_id) +{ + ACE_UNUSED_ARG (clock_id); +# if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_CONDATTR) + int result = -1; + +# if defined (_POSIX_CLOCK_SELECTION) && !defined (ACE_LACKS_CONDATTR_SETCLOCK) + ACE_ADAPT_RETVAL (pthread_condattr_setclock (&attributes, clock_id), result); +# else + ACE_UNUSED_ARG (attributes); +# endif /* _POSIX_CLOCK_SELECTION) && !ACE_LACKS_CONDATTR_SETCLOCK */ + + return result; +# else + ACE_UNUSED_ARG (attributes); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_PTHREADS && !ACE_LACKS_CONDATTR */ + +# else + ACE_UNUSED_ARG (attributes); + ACE_NOTSUP_RETURN (-1); +# endif /* ACE_HAS_THREADS */ +} + #if !defined (ACE_LACKS_COND_T) // NOTE: The ACE_OS::cond_* functions for Unix platforms are defined // here because the ACE_OS::sema_* functions below need them. @@ -390,7 +416,7 @@ ACE_OS::cond_timedwait (ACE_cond_t *cv, int msec_timeout = 0; if (timeout != 0) { - ACE_Time_Value relative_time (*timeout - ACE_OS::gettimeofday ()); + ACE_Time_Value relative_time = timeout->to_relative_time (); // Watchout for situations where a context switch has caused the // current time to be > the timeout. if (relative_time > ACE_Time_Value::zero) @@ -2153,7 +2179,7 @@ ACE_OS::sema_wait (ACE_sema_t *s, ACE_Time_Value &tv) { result = ACE_OS::sema_trywait (s); if (result == -1 && errno == EAGAIN) - expired = ACE_OS::gettimeofday () > tv; + expired = (tv.to_relative_time () <= ACE_Time_Value::zero); else expired = false; @@ -2176,7 +2202,7 @@ ACE_OS::sema_wait (ACE_sema_t *s, ACE_Time_Value &tv) error = ETIME; # if defined (ACE_LACKS_COND_TIMEDWAIT_RESET) - tv = ACE_OS::gettimeofday (); + tv = tv.now (); # endif /* ACE_LACKS_COND_TIMEDWAIT_RESET */ } @@ -2191,13 +2217,10 @@ ACE_OS::sema_wait (ACE_sema_t *s, ACE_Time_Value &tv) # endif /* ACE_HAS_POSIX_SEM_TIMEOUT */ # elif defined (ACE_USES_FIFO_SEM) int rc; - ACE_Time_Value now = ACE_OS::gettimeofday (); + ACE_Time_Value timeout = tv.to_relative_time (); - while (tv > now) + while (timeout > ACE_Time_Value::zero) { - ACE_Time_Value timeout = tv; - timeout -= now; - ACE_Handle_Set fds_; fds_.set_bit (s->fd_[0]); @@ -2217,7 +2240,7 @@ ACE_OS::sema_wait (ACE_sema_t *s, ACE_Time_Value &tv) // we were woken for input but someone beat us to it // so we wait again if there is still time - now = ACE_OS::gettimeofday (); + timeout = tv.to_relative_time (); } // make sure errno is set right @@ -2260,7 +2283,7 @@ ACE_OS::sema_wait (ACE_sema_t *s, ACE_Time_Value &tv) if (result == 0) { # if defined (ACE_LACKS_COND_TIMEDWAIT_RESET) - tv = ACE_OS::gettimeofday (); + tv = tv.now (); # endif /* ACE_LACKS_COND_TIMEDWAIT_RESET */ --s->count_; } @@ -2280,7 +2303,7 @@ ACE_OS::sema_wait (ACE_sema_t *s, ACE_Time_Value &tv) // Note that we must convert between absolute time (which is // passed as a parameter) and relative time (which is what // <WaitForSingleObjects> expects). - ACE_Time_Value relative_time (tv - ACE_OS::gettimeofday ()); + ACE_Time_Value relative_time = tv.to_relative_time (); // Watchout for situations where a context switch has caused the // current time to be > the timeout. @@ -2293,7 +2316,7 @@ ACE_OS::sema_wait (ACE_sema_t *s, ACE_Time_Value &tv) switch (::WaitForSingleObject (*s, msec_timeout)) { case WAIT_OBJECT_0: - tv = ACE_OS::gettimeofday (); // Update time to when acquired + tv = tv.now (); // Update time to when acquired return 0; case WAIT_TIMEOUT: errno = ETIME; @@ -2315,10 +2338,9 @@ ACE_OS::sema_wait (ACE_sema_t *s, ACE_Time_Value &tv) // as a shortcut for "now", which works on non-Windows because 0 is // always earlier than now. However, the need to convert to relative time // means we need to watch out for this case. - ACE_Time_Value end_time = tv; - if (tv == ACE_Time_Value::zero) - end_time = ACE_OS::gettimeofday (); - ACE_Time_Value relative_time = end_time - ACE_OS::gettimeofday (); + ACE_Time_Value relative_time (ACE_Time_Value::zero); + if (tv != ACE_Time_Value::zero) + relative_time = tv.to_relative_time (); int result = -1; // While we are not timeout yet. >= 0 will let this go through once @@ -2350,7 +2372,7 @@ ACE_OS::sema_wait (ACE_sema_t *s, ACE_Time_Value &tv) // Only return when we successfully get the semaphore. if (result == 0) { - tv = ACE_OS::gettimeofday (); // Update to time acquired + tv = tv.now (); // Update to time acquired return 0; } break; @@ -2369,7 +2391,8 @@ ACE_OS::sema_wait (ACE_sema_t *s, ACE_Time_Value &tv) // Haven't been able to get the semaphore yet, update the // timeout value to reflect the remaining time we want to wait. - relative_time = end_time - ACE_OS::gettimeofday (); + // in case of tv == 0 relative_time will now be < 0 and we will be out of time + relative_time = tv.to_relative_time (); } // We have timed out. @@ -2380,7 +2403,7 @@ ACE_OS::sema_wait (ACE_sema_t *s, ACE_Time_Value &tv) // Note that we must convert between absolute time (which is // passed as a parameter) and relative time (which is what // the system call expects). - ACE_Time_Value relative_time (tv - ACE_OS::gettimeofday ()); + ACE_Time_Value relative_time = tv.to_relative_time (); int ticks_per_sec = ::sysClkRateGet (); @@ -2398,7 +2421,7 @@ ACE_OS::sema_wait (ACE_sema_t *s, ACE_Time_Value &tv) } else { - tv = ACE_OS::gettimeofday (); // Update to time acquired + tv = tv.now (); // Update to time acquired return 0; } # endif /* ACE_HAS_STHREADS */ diff --git a/ACE/ace/Stream.cpp b/ACE/ace/Stream.cpp index d348353fef5..ba8ef031065 100644 --- a/ACE/ace/Stream.cpp +++ b/ACE/ace/Stream.cpp @@ -25,14 +25,14 @@ ACE_ALLOC_HOOK_DEFINE(ACE_Stream) // Give some idea of what the heck is going on in a stream! -template <ACE_SYNCH_DECL> void -ACE_Stream<ACE_SYNCH_USE>::dump (void) const +template <ACE_SYNCH_DECL, class TIME_POLICY> void +ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::dump (void) const { #if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::dump"); + ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::dump"); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("-------- module links --------\n"))); - for (ACE_Module<ACE_SYNCH_USE> *mp = this->stream_head_; + for (ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *mp = this->stream_head_; ; mp = mp->next ()) { @@ -43,7 +43,7 @@ ACE_Stream<ACE_SYNCH_USE>::dump (void) const ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("-------- writer links --------\n"))); - ACE_Task<ACE_SYNCH_USE> *tp; + ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *tp; for (tp = this->stream_head_->writer (); ; @@ -72,10 +72,10 @@ ACE_Stream<ACE_SYNCH_USE>::dump (void) const #endif /* ACE_HAS_DUMP */ } -template <ACE_SYNCH_DECL> int -ACE_Stream<ACE_SYNCH_USE>::push (ACE_Module<ACE_SYNCH_USE> *new_top) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::push (ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *new_top) { - ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::push"); + ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::push"); if (this->push_module (new_top, this->stream_head_->next (), this->stream_head_) == -1) @@ -84,27 +84,27 @@ ACE_Stream<ACE_SYNCH_USE>::push (ACE_Module<ACE_SYNCH_USE> *new_top) return 0; } -template <ACE_SYNCH_DECL> int -ACE_Stream<ACE_SYNCH_USE>::put (ACE_Message_Block *mb, ACE_Time_Value *tv) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::put (ACE_Message_Block *mb, ACE_Time_Value *tv) { - ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::put"); + ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::put"); return this->stream_head_->writer ()->put (mb, tv); } -template <ACE_SYNCH_DECL> int -ACE_Stream<ACE_SYNCH_USE>::get (ACE_Message_Block *&mb, ACE_Time_Value *tv) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::get (ACE_Message_Block *&mb, ACE_Time_Value *tv) { - ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::get"); + ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::get"); return this->stream_head_->reader ()->getq (mb, tv); } // Return the "top" ACE_Module in a ACE_Stream, skipping over the // stream_head. -template <ACE_SYNCH_DECL> int -ACE_Stream<ACE_SYNCH_USE>::top (ACE_Module<ACE_SYNCH_USE> *&m) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::top (ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *&m) { - ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::top"); + ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::top"); if (this->stream_head_->next () == this->stream_tail_) return -1; else @@ -114,18 +114,18 @@ ACE_Stream<ACE_SYNCH_USE>::top (ACE_Module<ACE_SYNCH_USE> *&m) } } -template <ACE_SYNCH_DECL> int -ACE_Stream<ACE_SYNCH_USE>::insert (const ACE_TCHAR *prev_name, - ACE_Module<ACE_SYNCH_USE> *mod) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::insert (const ACE_TCHAR *prev_name, + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *mod) { - ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::insert"); + ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::insert"); - for (ACE_Module<ACE_SYNCH_USE> *prev_mod = this->stream_head_; + for (ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *prev_mod = this->stream_head_; prev_mod != 0; prev_mod = prev_mod->next ()) if (ACE_OS::strcmp (prev_mod->name (), prev_name) == 0) { - ACE_Module<ACE_SYNCH_USE> *next_mod = prev_mod->next (); + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *next_mod = prev_mod->next (); // We can't insert a module below <stream_tail_>. if (next_mod == 0) @@ -146,20 +146,20 @@ ACE_Stream<ACE_SYNCH_USE>::insert (const ACE_TCHAR *prev_name, return -1; } -template <ACE_SYNCH_DECL> int -ACE_Stream<ACE_SYNCH_USE>::replace (const ACE_TCHAR *replace_name, - ACE_Module<ACE_SYNCH_USE> *mod, +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::replace (const ACE_TCHAR *replace_name, + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *mod, int flags) { - ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::replace"); - ACE_Module<ACE_SYNCH_USE> *prev_mod = 0; + ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::replace"); + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *prev_mod = 0; - for (ACE_Module<ACE_SYNCH_USE> *rep_mod = this->stream_head_; + for (ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *rep_mod = this->stream_head_; rep_mod != 0; rep_mod = rep_mod->next ()) if (ACE_OS::strcmp (rep_mod->name (), replace_name) == 0) { - ACE_Module<ACE_SYNCH_USE> *next_mod = rep_mod->next (); + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *next_mod = rep_mod->next (); if (next_mod) mod->link (next_mod); @@ -184,7 +184,7 @@ ACE_Stream<ACE_SYNCH_USE>::replace (const ACE_TCHAR *replace_name, if (mod->writer ()->open (mod->arg ()) == -1) return -1; - if (flags != ACE_Module<ACE_SYNCH_USE>::M_DELETE_NONE) + if (flags != ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::M_DELETE_NONE) { rep_mod->close (flags); delete rep_mod; @@ -201,17 +201,17 @@ ACE_Stream<ACE_SYNCH_USE>::replace (const ACE_TCHAR *replace_name, // Remove the "top" ACE_Module in a ACE_Stream, skipping over the // stream_head. -template <ACE_SYNCH_DECL> int -ACE_Stream<ACE_SYNCH_USE>::pop (int flags) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::pop (int flags) { - ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::pop"); + ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::pop"); if (this->stream_head_->next () == this->stream_tail_) return -1; else { // Skip over the ACE_Stream head. - ACE_Module<ACE_SYNCH_USE> *top_mod = this->stream_head_->next (); - ACE_Module<ACE_SYNCH_USE> *new_top = top_mod->next (); + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *top_mod = this->stream_head_->next (); + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *new_top = top_mod->next (); this->stream_head_->next (new_top); @@ -220,7 +220,7 @@ ACE_Stream<ACE_SYNCH_USE>::pop (int flags) top_mod->close (flags); // Don't delete the Module unless the flags request this. - if (flags != ACE_Module<ACE_SYNCH_USE>::M_DELETE_NONE) + if (flags != ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::M_DELETE_NONE) delete top_mod; this->stream_head_->writer ()->next (new_top->writer ()); @@ -232,14 +232,14 @@ ACE_Stream<ACE_SYNCH_USE>::pop (int flags) // Remove a named ACE_Module from an arbitrary place in the // ACE_Stream. -template <ACE_SYNCH_DECL> int -ACE_Stream<ACE_SYNCH_USE>::remove (const ACE_TCHAR *name, +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::remove (const ACE_TCHAR *name, int flags) { - ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::remove"); - ACE_Module<ACE_SYNCH_USE> *prev = 0; + ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::remove"); + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *prev = 0; - for (ACE_Module<ACE_SYNCH_USE> *mod = this->stream_head_; + for (ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *mod = this->stream_head_; mod != 0; mod = mod->next ()) { @@ -264,7 +264,7 @@ ACE_Stream<ACE_SYNCH_USE>::remove (const ACE_TCHAR *name, mod->close (flags); // Don't delete the Module unless the flags request this. - if (flags != ACE_Module<ACE_SYNCH_USE>::M_DELETE_NONE) + if (flags != ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::M_DELETE_NONE) { // Release the memory. delete mod; @@ -280,11 +280,11 @@ ACE_Stream<ACE_SYNCH_USE>::remove (const ACE_TCHAR *name, return -1; } -template <ACE_SYNCH_DECL> ACE_Module<ACE_SYNCH_USE> * -ACE_Stream<ACE_SYNCH_USE>::find (const ACE_TCHAR *name) +template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_Module<ACE_SYNCH_USE, TIME_POLICY> * +ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::find (const ACE_TCHAR *name) { - ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::find"); - for (ACE_Module<ACE_SYNCH_USE> *mod = this->stream_head_; + ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::find"); + for (ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *mod = this->stream_head_; mod != 0; mod = mod->next ()) if (ACE_OS::strcmp (mod->name (), name) == 0) @@ -295,16 +295,16 @@ ACE_Stream<ACE_SYNCH_USE>::find (const ACE_TCHAR *name) // Actually push a module onto the stack... -template <ACE_SYNCH_DECL> int -ACE_Stream<ACE_SYNCH_USE>::push_module (ACE_Module<ACE_SYNCH_USE> *new_top, - ACE_Module<ACE_SYNCH_USE> *current_top, - ACE_Module<ACE_SYNCH_USE> *head) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::push_module (ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *new_top, + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *current_top, + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *head) { - ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::push_module"); - ACE_Task<ACE_SYNCH_USE> *nt_reader = new_top->reader (); - ACE_Task<ACE_SYNCH_USE> *nt_writer = new_top->writer (); - ACE_Task<ACE_SYNCH_USE> *ct_reader = 0; - ACE_Task<ACE_SYNCH_USE> *ct_writer = 0; + ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::push_module"); + ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *nt_reader = new_top->reader (); + ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *nt_writer = new_top->writer (); + ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *ct_reader = 0; + ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *ct_writer = 0; if (current_top) { @@ -333,41 +333,45 @@ ACE_Stream<ACE_SYNCH_USE>::push_module (ACE_Module<ACE_SYNCH_USE> *new_top, return 0; } -template <ACE_SYNCH_DECL> int -ACE_Stream<ACE_SYNCH_USE>::open (void *a, - ACE_Module<ACE_SYNCH_USE> *head, - ACE_Module<ACE_SYNCH_USE> *tail) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::open (void *a, + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *head, + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *tail) { - ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::open"); + ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::open"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); - ACE_Task<ACE_SYNCH_USE> *h1 = 0, *h2 = 0; - ACE_Task<ACE_SYNCH_USE> *t1 = 0, *t2 = 0; + ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *h1 = 0, *h2 = 0; + ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *t1 = 0, *t2 = 0; if (head == 0) { + typedef ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY> STREAM_HEAD_TYPE; ACE_NEW_NORETURN (h1, - ACE_Stream_Head<ACE_SYNCH_USE>); + STREAM_HEAD_TYPE); ACE_NEW_NORETURN (h2, - ACE_Stream_Head<ACE_SYNCH_USE>); + STREAM_HEAD_TYPE); + typedef ACE_Module<ACE_SYNCH_USE, TIME_POLICY> MODULE_TYPE; ACE_NEW_NORETURN (head, - ACE_Module<ACE_SYNCH_USE> (ACE_TEXT ("ACE_Stream_Head"), - h1, h2, - a, - M_DELETE)); + MODULE_TYPE (ACE_TEXT ("ACE_Stream_Head"), + h1, h2, + a, + M_DELETE)); } if (tail == 0) { + typedef ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY> STREAM_TAIL_TYPE; ACE_NEW_NORETURN (t1, - ACE_Stream_Tail<ACE_SYNCH_USE>); + STREAM_TAIL_TYPE); ACE_NEW_NORETURN (t2, - ACE_Stream_Tail<ACE_SYNCH_USE>); + STREAM_TAIL_TYPE); + typedef ACE_Module<ACE_SYNCH_USE, TIME_POLICY> MODULE_TYPE; ACE_NEW_NORETURN (tail, - ACE_Module<ACE_SYNCH_USE> (ACE_TEXT ("ACE_Stream_Tail"), - t1, t2, - a, - M_DELETE)); + MODULE_TYPE (ACE_TEXT ("ACE_Stream_Tail"), + t1, t2, + a, + M_DELETE)); } // Make sure *all* the allocation succeeded! @@ -397,10 +401,10 @@ ACE_Stream<ACE_SYNCH_USE>::open (void *a, return 0; } -template <ACE_SYNCH_DECL> int -ACE_Stream<ACE_SYNCH_USE>::close (int flags) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::close (int flags) { - ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::close"); + ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::close"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); if (this->stream_head_ != 0 @@ -437,11 +441,11 @@ ACE_Stream<ACE_SYNCH_USE>::close (int flags) return 0; } -template <ACE_SYNCH_DECL> int -ACE_Stream<ACE_SYNCH_USE>::control (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd, +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::control (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd, void *a) { - ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::control"); + ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::control"); ACE_IO_Cntl_Msg ioc (cmd); ACE_Message_Block *db = 0; @@ -496,15 +500,15 @@ ACE_Stream<ACE_SYNCH_USE>::control (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd, // on the fact that the Stream head and Stream tail are non-NULL... // This must be called with locks held. -template <ACE_SYNCH_DECL> int -ACE_Stream<ACE_SYNCH_USE>::link_i (ACE_Stream<ACE_SYNCH_USE> &us) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::link_i (ACE_Stream<ACE_SYNCH_USE, TIME_POLICY> &us) { - ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::link_i"); + ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::link_i"); this->linked_us_ = &us; // Make sure the other side is also linked to us! us.linked_us_ = this; - ACE_Module<ACE_SYNCH_USE> *my_tail = this->stream_head_; + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *my_tail = this->stream_head_; if (my_tail == 0) return -1; @@ -513,7 +517,7 @@ ACE_Stream<ACE_SYNCH_USE>::link_i (ACE_Stream<ACE_SYNCH_USE> &us) while (my_tail->next () != this->stream_tail_) my_tail = my_tail->next (); - ACE_Module<ACE_SYNCH_USE> *other_tail = us.stream_head_; + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *other_tail = us.stream_head_; if (other_tail == 0) return -1; @@ -528,10 +532,10 @@ ACE_Stream<ACE_SYNCH_USE>::link_i (ACE_Stream<ACE_SYNCH_USE> &us) return 0; } -template <ACE_SYNCH_DECL> int -ACE_Stream<ACE_SYNCH_USE>::link (ACE_Stream<ACE_SYNCH_USE> &us) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::link (ACE_Stream<ACE_SYNCH_USE, TIME_POLICY> &us) { - ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::link"); + ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::link"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); @@ -540,16 +544,16 @@ ACE_Stream<ACE_SYNCH_USE>::link (ACE_Stream<ACE_SYNCH_USE> &us) // Must be called with locks held... -template <ACE_SYNCH_DECL> int -ACE_Stream<ACE_SYNCH_USE>::unlink_i (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::unlink_i (void) { - ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::unlink_i"); + ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::unlink_i"); // Only try to unlink if we are in fact still linked! if (this->linked_us_ != 0) { - ACE_Module<ACE_SYNCH_USE> *my_tail = this->stream_head_; + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *my_tail = this->stream_head_; // Only relink if we still exist! if (my_tail) @@ -562,7 +566,7 @@ ACE_Stream<ACE_SYNCH_USE>::unlink_i (void) my_tail->writer ()->next (this->stream_tail_->writer ()); } - ACE_Module<ACE_SYNCH_USE> *other_tail = + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *other_tail = this->linked_us_->stream_head_; // Only fiddle with the other side if it in fact still remains. @@ -585,44 +589,44 @@ ACE_Stream<ACE_SYNCH_USE>::unlink_i (void) return -1; } -template <ACE_SYNCH_DECL> int -ACE_Stream<ACE_SYNCH_USE>::unlink (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::unlink (void) { - ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::unlink"); + ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::unlink"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); return this->unlink_i (); } -template <ACE_SYNCH_DECL> -ACE_Stream<ACE_SYNCH_USE>::ACE_Stream (void * a, - ACE_Module<ACE_SYNCH_USE> *head, - ACE_Module<ACE_SYNCH_USE> *tail) +template <ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::ACE_Stream (void * a, + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *head, + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *tail) : stream_head_ (0), stream_tail_ (0), linked_us_ (0), - final_close_ (lock_) + final_close_ (lock_, ACE_Condition_Attributes_T<TIME_POLICY> ()) { - ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::ACE_Stream"); + ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::ACE_Stream"); if (this->open (a, head, tail) == -1) ACE_ERROR ((LM_ERROR, - ACE_TEXT ("ACE_Stream<ACE_SYNCH_USE>::open (%s, %s)\n"), + ACE_TEXT ("ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::open (%s, %s)\n"), head->name (), tail->name ())); } -template <ACE_SYNCH_DECL> -ACE_Stream<ACE_SYNCH_USE>::~ACE_Stream (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::~ACE_Stream (void) { - ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::~ACE_Stream"); + ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::~ACE_Stream"); if (this->stream_head_ != 0) this->close (); } -template <ACE_SYNCH_DECL> -ACE_Stream_Iterator<ACE_SYNCH_USE>::ACE_Stream_Iterator (const ACE_Stream<ACE_SYNCH_USE> &sr) +template <ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Stream_Iterator<ACE_SYNCH_USE, TIME_POLICY>::ACE_Stream_Iterator (const ACE_Stream<ACE_SYNCH_USE, TIME_POLICY> &sr) : next_ (sr.stream_head_) { - ACE_TRACE ("ACE_Stream_Iterator<ACE_SYNCH_USE>::ACE_Stream_Iterator"); + ACE_TRACE ("ACE_Stream_Iterator<ACE_SYNCH_USE, TIME_POLICY>::ACE_Stream_Iterator"); } ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Stream.h b/ACE/ace/Stream.h index 1caed488777..5d72a377074 100644 --- a/ACE/ace/Stream.h +++ b/ACE/ace/Stream.h @@ -28,7 +28,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL // Forward decls. -template<ACE_SYNCH_DECL> class ACE_Stream_Iterator; +template<ACE_SYNCH_DECL, class TIME_POLICY> class ACE_Stream_Iterator; class ACE_Time_Value; /** @@ -45,11 +45,11 @@ class ACE_Time_Value; * won't be overridden properly unless you call it in a subclass * destructor. */ -template <ACE_SYNCH_DECL> +template <ACE_SYNCH_DECL, class TIME_POLICY = ACE_System_Time_Policy> class ACE_Stream { public: - friend class ACE_Stream_Iterator<ACE_SYNCH_USE>; + friend class ACE_Stream_Iterator<ACE_SYNCH_USE, TIME_POLICY>; enum { @@ -66,8 +66,8 @@ public: * @a arg is the value past in to the <open> methods of the tasks. */ ACE_Stream (void *arg = 0, - ACE_Module<ACE_SYNCH_USE> *head = 0, - ACE_Module<ACE_SYNCH_USE> *tail = 0); + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *head = 0, + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *tail = 0); /** * Create a Stream consisting of @a head and @a tail as the Stream @@ -76,8 +76,8 @@ public: * @a arg is the value past in to the @c open() methods of the tasks. */ virtual int open (void *arg, - ACE_Module<ACE_SYNCH_USE> *head = 0, - ACE_Module<ACE_SYNCH_USE> *tail = 0); + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *head = 0, + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *tail = 0); /// Close down the stream and release all the resources. virtual int close (int flags = M_DELETE); @@ -90,7 +90,7 @@ public: /// Add a new module @a mod right below the Stream head. The /// @c open() hook methods of the @c ACE_Tasks in this ACE_Module /// are invoked to initialize the tasks. - virtual int push (ACE_Module<ACE_SYNCH_USE> *mod); + virtual int push (ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *mod); /// Remove the @a mod right below the Stream head and close it down. // The <close()> hook methods of the <ACE_Tasks> in this ACE_Module @@ -99,15 +99,15 @@ public: /// Return the top module on the stream (right below the stream /// head). - virtual int top (ACE_Module<ACE_SYNCH_USE> *&mod); + virtual int top (ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *&mod); /// Insert a new module @a mod below the named module @a prev_name. virtual int insert (const ACE_TCHAR *prev_name, - ACE_Module<ACE_SYNCH_USE> *mod); + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *mod); /// Replace the named module @a replace_name with a new module @a mod. virtual int replace (const ACE_TCHAR *replace_name, - ACE_Module<ACE_SYNCH_USE> *mod, + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *mod, int flags = M_DELETE); /// Remove the named module @a mod from the stream. This bypasses the @@ -116,16 +116,16 @@ public: int flags = M_DELETE); /// Return current stream head. - virtual ACE_Module<ACE_SYNCH_USE> *head (void); + virtual ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *head (void); /// Return current stream tail. - virtual ACE_Module<ACE_SYNCH_USE> *tail (void); + virtual ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *tail (void); /// Find a particular ACE_Module. - virtual ACE_Module<ACE_SYNCH_USE> *find (const ACE_TCHAR *mod); + virtual ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *find (const ACE_TCHAR *mod); /// Create a pipe between two Streams. - virtual int link (ACE_Stream<ACE_SYNCH_USE> &); + virtual int link (ACE_Stream<ACE_SYNCH_USE, TIME_POLICY> &); /// Remove a pipe formed between two Streams. virtual int unlink (void); @@ -168,21 +168,21 @@ private: /// Actually perform the linking of two Streams (must be called with /// locks held). - int link_i (ACE_Stream<ACE_SYNCH_USE> &); + int link_i (ACE_Stream<ACE_SYNCH_USE, TIME_POLICY> &); /// Must a new module onto the Stream. - int push_module (ACE_Module<ACE_SYNCH_USE> *, - ACE_Module<ACE_SYNCH_USE> * = 0, - ACE_Module<ACE_SYNCH_USE> * = 0); + int push_module (ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *, + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> * = 0, + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> * = 0); /// Pointer to the head of the stream. - ACE_Module<ACE_SYNCH_USE> *stream_head_; + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *stream_head_; /// Pointer to the tail of the stream. - ACE_Module<ACE_SYNCH_USE> *stream_tail_; + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *stream_tail_; /// Pointer to an adjoining linked stream. - ACE_Stream<ACE_SYNCH_USE> *linked_us_; + ACE_Stream<ACE_SYNCH_USE, TIME_POLICY> *linked_us_; // = Synchronization objects used for thread-safe streams. /// Protect the stream against race conditions. @@ -197,18 +197,18 @@ private: * * @brief Iterate through an ACE_Stream. */ -template <ACE_SYNCH_DECL> +template <ACE_SYNCH_DECL, class TIME_POLICY = ACE_System_Time_Policy> class ACE_Stream_Iterator { public: // = Initialization method. - ACE_Stream_Iterator (const ACE_Stream<ACE_SYNCH_USE> &sr); + ACE_Stream_Iterator (const ACE_Stream<ACE_SYNCH_USE, TIME_POLICY> &sr); // = Iteration methods. /// Pass back the @a next_item that hasn't been seen in the set. /// Returns 0 when all items have been seen, else 1. - int next (const ACE_Module<ACE_SYNCH_USE> *&next_item); + int next (const ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *&next_item); /// Returns 1 when all items have been seen, else 0. int done (void) const; @@ -219,7 +219,7 @@ public: private: /// Next ACE_Module that we haven't yet seen. - ACE_Module<ACE_SYNCH_USE> *next_; + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *next_; }; ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Stream.inl b/ACE/ace/Stream.inl index 24ff6840431..c46e33922e7 100644 --- a/ACE/ace/Stream.inl +++ b/ACE/ace/Stream.inl @@ -4,46 +4,46 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -template <ACE_SYNCH_DECL> ACE_INLINE ACE_Module<ACE_SYNCH_USE> * -ACE_Stream<ACE_SYNCH_USE>::head (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_INLINE ACE_Module<ACE_SYNCH_USE, TIME_POLICY> * +ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::head (void) { - ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::head"); + ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::head"); return this->stream_head_; } -template <ACE_SYNCH_DECL> ACE_INLINE ACE_Module<ACE_SYNCH_USE> * -ACE_Stream<ACE_SYNCH_USE>::tail (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_INLINE ACE_Module<ACE_SYNCH_USE, TIME_POLICY> * +ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::tail (void) { - ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::tail"); + ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::tail"); return this->stream_tail_; } -template <ACE_SYNCH_DECL> ACE_INLINE int -ACE_Stream<ACE_SYNCH_USE>::wait (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_INLINE int +ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::wait (void) { - ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE>::wait"); + ACE_TRACE ("ACE_Stream<ACE_SYNCH_USE, TIME_POLICY>::wait"); return this->final_close_.wait (); } -template <ACE_SYNCH_DECL> ACE_INLINE int -ACE_Stream_Iterator<ACE_SYNCH_USE>::next (const ACE_Module<ACE_SYNCH_USE> *&mod) +template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_INLINE int +ACE_Stream_Iterator<ACE_SYNCH_USE, TIME_POLICY>::next (const ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *&mod) { - ACE_TRACE ("ACE_Stream_Iterator<ACE_SYNCH_USE>::next"); + ACE_TRACE ("ACE_Stream_Iterator<ACE_SYNCH_USE, TIME_POLICY>::next"); mod = this->next_; return this->next_ != 0; } -template <ACE_SYNCH_DECL> ACE_INLINE int -ACE_Stream_Iterator<ACE_SYNCH_USE>::done (void) const +template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_INLINE int +ACE_Stream_Iterator<ACE_SYNCH_USE, TIME_POLICY>::done (void) const { - ACE_TRACE ("ACE_Stream_Iterator<ACE_SYNCH_USE>::done"); + ACE_TRACE ("ACE_Stream_Iterator<ACE_SYNCH_USE, TIME_POLICY>::done"); return this->next_ == 0; } -template <ACE_SYNCH_DECL> int -ACE_Stream_Iterator<ACE_SYNCH_USE>::advance (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream_Iterator<ACE_SYNCH_USE, TIME_POLICY>::advance (void) { - ACE_TRACE ("ACE_Stream_Iterator<ACE_SYNCH_USE>::advance"); + ACE_TRACE ("ACE_Stream_Iterator<ACE_SYNCH_USE, TIME_POLICY>::advance"); this->next_ = this->next_->next (); return this->next_ != 0; } diff --git a/ACE/ace/Stream_Modules.cpp b/ACE/ace/Stream_Modules.cpp index 69163951323..3cfa8843ff2 100644 --- a/ACE/ace/Stream_Modules.cpp +++ b/ACE/ace/Stream_Modules.cpp @@ -15,53 +15,53 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_ALLOC_HOOK_DEFINE(ACE_Stream_Head) -template <ACE_SYNCH_DECL> -ACE_Stream_Head<ACE_SYNCH_USE>::ACE_Stream_Head (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::ACE_Stream_Head (void) { - ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::ACE_Stream_Head"); + ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::ACE_Stream_Head"); } -template <ACE_SYNCH_DECL> -ACE_Stream_Head<ACE_SYNCH_USE>::~ACE_Stream_Head (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::~ACE_Stream_Head (void) { - ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::~ACE_Stream_Head"); + ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::~ACE_Stream_Head"); } -template <ACE_SYNCH_DECL> void -ACE_Stream_Head<ACE_SYNCH_USE>::dump (void) const +template <ACE_SYNCH_DECL, class TIME_POLICY> void +ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::dump (void) const { #if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::dump"); + ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::dump"); #endif /* ACE_HAS_DUMP */ } // ACE_Module that act as the head and tail of a Stream. -template <ACE_SYNCH_DECL> int -ACE_Stream_Head<ACE_SYNCH_USE>::open (void *) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::open (void *) { - ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::open"); + ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::open"); return 0; } -template <ACE_SYNCH_DECL> int -ACE_Stream_Head<ACE_SYNCH_USE>::close (u_long) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::close (u_long) { - ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::close"); + ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::close"); return 0; } -template <ACE_SYNCH_DECL> int -ACE_Stream_Head<ACE_SYNCH_USE>::svc (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::svc (void) { - ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::svc"); + ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::svc"); return -1; } -template <ACE_SYNCH_DECL> int -ACE_Stream_Head<ACE_SYNCH_USE>::control (ACE_Message_Block *mb) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::control (ACE_Message_Block *mb) { - ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::control"); + ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::control"); ACE_IO_Cntl_Msg *ioc = (ACE_IO_Cntl_Msg *) mb->rd_ptr (); ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd; @@ -80,10 +80,10 @@ ACE_Stream_Head<ACE_SYNCH_USE>::control (ACE_Message_Block *mb) // Performs canonical flushing at the ACE_Stream Head. -template <ACE_SYNCH_DECL> int -ACE_Stream_Head<ACE_SYNCH_USE>::canonical_flush (ACE_Message_Block *mb) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::canonical_flush (ACE_Message_Block *mb) { - ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::canonical_flush"); + ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::canonical_flush"); char *cp = mb->rd_ptr (); if (ACE_BIT_ENABLED (*cp, ACE_Task_Flags::ACE_FLUSHR)) @@ -99,11 +99,11 @@ ACE_Stream_Head<ACE_SYNCH_USE>::canonical_flush (ACE_Message_Block *mb) return 0; } -template <ACE_SYNCH_DECL> int -ACE_Stream_Head<ACE_SYNCH_USE>::put (ACE_Message_Block *mb, +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::put (ACE_Message_Block *mb, ACE_Time_Value *tv) { - ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::put"); + ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::put"); int res = 0; if (mb->msg_type () == ACE_Message_Block::MB_IOCTL @@ -126,17 +126,17 @@ ACE_Stream_Head<ACE_SYNCH_USE>::put (ACE_Message_Block *mb, } } -template <ACE_SYNCH_DECL> int -ACE_Stream_Head<ACE_SYNCH_USE>::init (int, ACE_TCHAR *[]) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::init (int, ACE_TCHAR *[]) { - ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::init"); + ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::init"); return 0; } -template <ACE_SYNCH_DECL> int -ACE_Stream_Head<ACE_SYNCH_USE>::info (ACE_TCHAR **strp, size_t length) const +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::info (ACE_TCHAR **strp, size_t length) const { - ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::info"); + ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::info"); const ACE_TCHAR *name = this->name (); if (*strp == 0 && (*strp = ACE_OS::strdup (name)) == 0) @@ -146,60 +146,60 @@ ACE_Stream_Head<ACE_SYNCH_USE>::info (ACE_TCHAR **strp, size_t length) const return static_cast<int> (ACE_OS::strlen (name)); } -template <ACE_SYNCH_DECL> int -ACE_Stream_Head<ACE_SYNCH_USE>::fini (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::fini (void) { - ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE>::fini"); + ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::fini"); return 0; } ACE_ALLOC_HOOK_DEFINE(ACE_Stream_Tail) -template <ACE_SYNCH_DECL> -ACE_Stream_Tail<ACE_SYNCH_USE>::ACE_Stream_Tail (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::ACE_Stream_Tail (void) { - ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::ACE_Stream_Tail"); + ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::ACE_Stream_Tail"); } -template <ACE_SYNCH_DECL> -ACE_Stream_Tail<ACE_SYNCH_USE>::~ACE_Stream_Tail (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::~ACE_Stream_Tail (void) { - ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::~ACE_Stream_Tail"); + ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::~ACE_Stream_Tail"); } -template <ACE_SYNCH_DECL> void -ACE_Stream_Tail<ACE_SYNCH_USE>::dump (void) const +template <ACE_SYNCH_DECL, class TIME_POLICY> void +ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::dump (void) const { #if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::dump"); + ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::dump"); #endif /* ACE_HAS_DUMP */ } -template <ACE_SYNCH_DECL> int -ACE_Stream_Tail<ACE_SYNCH_USE>::open (void *) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::open (void *) { - ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::open"); + ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::open"); return 0; } -template <ACE_SYNCH_DECL> int -ACE_Stream_Tail<ACE_SYNCH_USE>::close (u_long) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::close (u_long) { - ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::close"); + ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::close"); return 0; } -template <ACE_SYNCH_DECL> int -ACE_Stream_Tail<ACE_SYNCH_USE>::svc (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::svc (void) { - ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::svc"); + ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::svc"); return -1; } -template <ACE_SYNCH_DECL> int -ACE_Stream_Tail<ACE_SYNCH_USE>::control (ACE_Message_Block *mb) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::control (ACE_Message_Block *mb) { - ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::control"); + ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::control"); ACE_IO_Cntl_Msg *ioc = (ACE_IO_Cntl_Msg *) mb->rd_ptr (); ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd; @@ -217,16 +217,17 @@ ACE_Stream_Tail<ACE_SYNCH_USE>::control (ACE_Message_Block *mb) } default: mb->msg_type (ACE_Message_Block::MB_IOCNAK); + break; } return this->reply (mb); } // Perform flush algorithm as though we were the driver. -template <ACE_SYNCH_DECL> int -ACE_Stream_Tail<ACE_SYNCH_USE>::canonical_flush (ACE_Message_Block *mb) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::canonical_flush (ACE_Message_Block *mb) { - ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::canonical_flush"); + ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::canonical_flush"); char *cp = mb->rd_ptr (); if (ACE_BIT_ENABLED (*cp, ACE_Task_Flags::ACE_FLUSHW)) @@ -246,11 +247,11 @@ ACE_Stream_Tail<ACE_SYNCH_USE>::canonical_flush (ACE_Message_Block *mb) return 0; } -template <ACE_SYNCH_DECL> int -ACE_Stream_Tail<ACE_SYNCH_USE>::put (ACE_Message_Block *mb, +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::put (ACE_Message_Block *mb, ACE_Time_Value *) { - ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::put"); + ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::put"); if (this->is_writer ()) { @@ -269,17 +270,17 @@ ACE_Stream_Tail<ACE_SYNCH_USE>::put (ACE_Message_Block *mb, return -1; } -template <ACE_SYNCH_DECL> int -ACE_Stream_Tail<ACE_SYNCH_USE>::init (int, ACE_TCHAR *[]) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::init (int, ACE_TCHAR *[]) { - ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::init"); + ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::init"); return 0; } -template <ACE_SYNCH_DECL> int -ACE_Stream_Tail<ACE_SYNCH_USE>::info (ACE_TCHAR **strp, size_t length) const +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::info (ACE_TCHAR **strp, size_t length) const { - ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::info"); + ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::info"); const ACE_TCHAR *name = this->name (); if (*strp == 0 && (*strp = ACE_OS::strdup (name)) == 0) @@ -289,76 +290,76 @@ ACE_Stream_Tail<ACE_SYNCH_USE>::info (ACE_TCHAR **strp, size_t length) const return static_cast<int> (ACE_OS::strlen (name)); } -template <ACE_SYNCH_DECL> int -ACE_Stream_Tail<ACE_SYNCH_USE>::fini (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::fini (void) { - ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE>::fini"); + ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::fini"); return 0; } ACE_ALLOC_HOOK_DEFINE(ACE_Thru_Task) -template <ACE_SYNCH_DECL> -ACE_Thru_Task<ACE_SYNCH_USE>::ACE_Thru_Task (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::ACE_Thru_Task (void) { - ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE>::ACE_Thru_Task"); + ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::ACE_Thru_Task"); } -template <ACE_SYNCH_DECL> -ACE_Thru_Task<ACE_SYNCH_USE>::~ACE_Thru_Task (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::~ACE_Thru_Task (void) { - ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE>::~ACE_Thru_Task"); + ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::~ACE_Thru_Task"); } -template <ACE_SYNCH_DECL> void -ACE_Thru_Task<ACE_SYNCH_USE>::dump (void) const +template <ACE_SYNCH_DECL, class TIME_POLICY> void +ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::dump (void) const { #if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE>::dump"); + ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::dump"); #endif /* ACE_HAS_DUMP */ } -template <ACE_SYNCH_DECL> int -ACE_Thru_Task<ACE_SYNCH_USE>::open (void *) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::open (void *) { - ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE>::open"); + ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::open"); return 0; } -template <ACE_SYNCH_DECL> int -ACE_Thru_Task<ACE_SYNCH_USE>::close (u_long) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::close (u_long) { - ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE>::close"); + ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::close"); return 0; } -template <ACE_SYNCH_DECL> int -ACE_Thru_Task<ACE_SYNCH_USE>::svc (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::svc (void) { - ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE>::svc"); + ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::svc"); return -1; } -template <ACE_SYNCH_DECL> int -ACE_Thru_Task<ACE_SYNCH_USE>::put (ACE_Message_Block *msg, +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::put (ACE_Message_Block *msg, ACE_Time_Value *tv) { - ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE>::put"); + ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::put"); return this->put_next (msg, tv); } -template <ACE_SYNCH_DECL> int -ACE_Thru_Task<ACE_SYNCH_USE>::init (int, ACE_TCHAR *[]) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::init (int, ACE_TCHAR *[]) { - ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE>::init"); + ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::init"); return 0; } -template <ACE_SYNCH_DECL> int -ACE_Thru_Task<ACE_SYNCH_USE>::info (ACE_TCHAR **strp, +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::info (ACE_TCHAR **strp, size_t length) const { - ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE>::info"); + ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::info"); const ACE_TCHAR *name = this->name (); if (*strp == 0 && (*strp = ACE_OS::strdup (name)) == 0) @@ -368,10 +369,10 @@ ACE_Thru_Task<ACE_SYNCH_USE>::info (ACE_TCHAR **strp, return static_cast<int> (ACE_OS::strlen (name)); } -template <ACE_SYNCH_DECL> int -ACE_Thru_Task<ACE_SYNCH_USE>::fini (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> int +ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::fini (void) { - ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE>::fini"); + ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::fini"); return 0; } diff --git a/ACE/ace/Stream_Modules.h b/ACE/ace/Stream_Modules.h index 10d396c95f5..af713ca2079 100644 --- a/ACE/ace/Stream_Modules.h +++ b/ACE/ace/Stream_Modules.h @@ -47,15 +47,15 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL * stream. * - Writer: The block is passed to the next module in the stream. */ -template <ACE_SYNCH_DECL> -class ACE_Stream_Head : public ACE_Task<ACE_SYNCH_USE> +template <ACE_SYNCH_DECL, class TIME_POLICY = ACE_System_Time_Policy> +class ACE_Stream_Head : public ACE_Task<ACE_SYNCH_USE, TIME_POLICY> { public: /// Construction ACE_Stream_Head (void); /// Destruction - ~ACE_Stream_Head (void); + virtual ~ACE_Stream_Head (void); // = ACE_Task hooks virtual int open (void *a = 0); @@ -85,15 +85,15 @@ private: * * @brief Standard module that acts as the head of a stream. */ -template <ACE_SYNCH_DECL> -class ACE_Stream_Tail : public ACE_Task<ACE_SYNCH_USE> +template <ACE_SYNCH_DECL, class TIME_POLICY = ACE_System_Time_Policy> +class ACE_Stream_Tail : public ACE_Task<ACE_SYNCH_USE, TIME_POLICY> { public: /// Construction ACE_Stream_Tail (void); /// Destruction - ~ACE_Stream_Tail (void); + virtual ~ACE_Stream_Tail (void); // = ACE_Task hooks virtual int open (void *a = 0); @@ -124,15 +124,15 @@ private: * @brief Standard module that acts as a "no op", simply passing on all * data to its adjacent neighbor. */ -template <ACE_SYNCH_DECL> -class ACE_Thru_Task : public ACE_Task<ACE_SYNCH_USE> +template <ACE_SYNCH_DECL, class TIME_POLICY = ACE_System_Time_Policy> +class ACE_Thru_Task : public ACE_Task<ACE_SYNCH_USE, TIME_POLICY> { public: /// Construction ACE_Thru_Task (void); /// Destruction - ~ACE_Thru_Task (void); + virtual ~ACE_Thru_Task (void); // = ACE_Task hooks virtual int open (void *a = 0); diff --git a/ACE/ace/Synch_Traits.h b/ACE/ace/Synch_Traits.h index 1fe6d483692..01e2ecb3db6 100644 --- a/ACE/ace/Synch_Traits.h +++ b/ACE/ace/Synch_Traits.h @@ -27,17 +27,19 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL // Forward decl class ACE_Null_Mutex; -class ACE_Null_Condition; class ACE_Null_Semaphore; class ACE_Null_Mutex; class ACE_Thread_Mutex; class ACE_Process_Mutex; class ACE_Recursive_Thread_Mutex; class ACE_RW_Thread_Mutex; -class ACE_Condition_Thread_Mutex; -class ACE_Condition_Recursive_Thread_Mutex; class ACE_Thread_Semaphore; +template <class ACE_LOCK> class ACE_Condition; +typedef ACE_Condition<ACE_Null_Mutex> ACE_Null_Condition; +typedef ACE_Condition<ACE_Thread_Mutex> ACE_Condition_Thread_Mutex; +typedef ACE_Condition<ACE_Recursive_Thread_Mutex> ACE_Condition_Recursive_Thread_Mutex; + /** * @class ACE_NULL_SYNCH * @@ -62,7 +64,6 @@ public: #if defined (ACE_HAS_THREADS) class ACE_Process_Mutex; -class ACE_Condition_Recursive_Thread_Mutex; /** * @class ACE_MT_SYNCH diff --git a/ACE/ace/Task_Ex_T.cpp b/ACE/ace/Task_Ex_T.cpp index 1a3848d6ccb..b688c1ba994 100644 --- a/ACE/ace/Task_Ex_T.cpp +++ b/ACE/ace/Task_Ex_T.cpp @@ -19,11 +19,11 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -template <ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE> void -ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE>::dump (void) const +template <ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE, class TIME_POLICY> void +ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE, TIME_POLICY>::dump (void) const { #if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE>::dump"); + ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE, TIME_POLICY>::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nthr_mgr_ = %x"), this->thr_mgr_)); this->msg_queue_->dump (); @@ -44,31 +44,31 @@ ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE>::dump (void) const // If the user doesn't supply a ACE_Message_Queue_Ex pointer then we'll // allocate one dynamically. Otherwise, we'll use the one they give. -template<ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE> -ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE>::ACE_Task_Ex (ACE_Thread_Manager *thr_man, - ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE> *mq) +template<ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE, class TIME_POLICY> +ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE, TIME_POLICY>::ACE_Task_Ex (ACE_Thread_Manager *thr_man, + ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY> *mq) : ACE_Task_Base (thr_man), msg_queue_ (0), delete_msg_queue_ (false), mod_ (0), next_ (0) { - ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE>::ACE_Task_Ex"); + ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE, TIME_POLICY>::ACE_Task_Ex"); if (mq == 0) { ACE_NEW (mq, - (ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>)); + (ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>)); this->delete_msg_queue_ = true; } this->msg_queue_ = mq; } -template<ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE> -ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE>::~ACE_Task_Ex (void) +template<ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE, class TIME_POLICY> +ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE, TIME_POLICY>::~ACE_Task_Ex (void) { - ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE>::~ACE_Task_Ex"); + ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE, TIME_POLICY>::~ACE_Task_Ex"); if (this->delete_msg_queue_) delete this->msg_queue_; @@ -77,10 +77,10 @@ ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE>::~ACE_Task_Ex (void) this->delete_msg_queue_ = false; } -template<ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE> ACE_Task<ACE_SYNCH_USE> * -ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE>::sibling (void) +template<ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE, class TIME_POLICY> ACE_Task<ACE_SYNCH_USE, TIME_POLICY> * +ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE, TIME_POLICY>::sibling (void) { - ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE>::sibling"); + ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE, TIME_POLICY>::sibling"); /// @todo FIXME Need to impl ACE_Moudle to support ACE_Task as well. /// Now always return 0 for sibling return 0; @@ -92,20 +92,20 @@ ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE>::sibling (void) */ } -template<ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE> const ACE_TCHAR * -ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE>::name (void) const +template<ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE, class TIME_POLICY> const ACE_TCHAR * +ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE, TIME_POLICY>::name (void) const { - ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE>::name"); + ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE, TIME_POLICY>::name"); if (this->mod_ == 0) return 0; else return this->mod_->name (); } -template<ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE> ACE_Module<ACE_SYNCH_USE> * -ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE>::module (void) const +template<ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE, class TIME_POLICY> ACE_Module<ACE_SYNCH_USE, TIME_POLICY> * +ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE, TIME_POLICY>::module (void) const { - ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE>::module"); + ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE, TIME_POLICY>::module"); return this->mod_; } diff --git a/ACE/ace/Task_Ex_T.h b/ACE/ace/Task_Ex_T.h index c652a51d674..e50c4d240eb 100644 --- a/ACE/ace/Task_Ex_T.h +++ b/ACE/ace/Task_Ex_T.h @@ -26,7 +26,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL // Forward decls... -template <ACE_SYNCH_DECL> class ACE_Module; +template <ACE_SYNCH_DECL, class TIME_POLICY> class ACE_Module; /** * @class ACE_Task_Ex @@ -57,14 +57,14 @@ template <ACE_SYNCH_DECL> class ACE_Module; * When User (and legacy code) write ACE_Task<ACE_MT_SYNCH>, specialized ACE_Task * code is in action. */ -template <ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE> +template <ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE, class TIME_POLICY = ACE_System_Time_Policy> class ACE_Task_Ex : public ACE_Task_Base, private ACE_Copy_Disabled { public: - friend class ACE_Module<ACE_SYNCH_USE>; + friend class ACE_Module<ACE_SYNCH_USE, TIME_POLICY>; friend class ACE_Module_Type; - typedef ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE> MESSAGE_QUEUE_EX; + typedef ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY> MESSAGE_QUEUE_EX; // = Initialization/termination methods. /** @@ -133,16 +133,16 @@ public: // Should be protected: // = Pointers to next ACE_Task_Base (if ACE is part of an ACE_Stream). /// Get next Task pointer. - ACE_Task<ACE_SYNCH_USE> *next (void); + ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *next (void); /// Set next Task pointer. - void next (ACE_Task<ACE_SYNCH_USE> *); + void next (ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *); /// Alwasy return 0. @todo FIXME - ACE_Task<ACE_SYNCH_USE> *sibling (void); + ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *sibling (void); /// Return the Task's Module if there is one, else returns 0. - ACE_Module<ACE_SYNCH_USE> *module (void) const; + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *module (void) const; /** * Flush the task's queue, i.e., free all of the enqueued @@ -164,10 +164,10 @@ public: // Should be protected: bool delete_msg_queue_; /// Back-pointer to the enclosing module. - ACE_Module<ACE_SYNCH_USE> *mod_; + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *mod_; /// Pointer to adjacent ACE_Task. - ACE_Task<ACE_SYNCH_USE> *next_; + ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *next_; /// Dump the state of an object. void dump (void) const; diff --git a/ACE/ace/Task_Ex_T.inl b/ACE/ace/Task_Ex_T.inl index 51522b16cbf..87d4f18fbe6 100644 --- a/ACE/ace/Task_Ex_T.inl +++ b/ACE/ace/Task_Ex_T.inl @@ -4,52 +4,52 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -template <ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE> ACE_INLINE void -ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE>::water_marks (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd, +template <ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE, class TIME_POLICY> ACE_INLINE void +ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE, TIME_POLICY>::water_marks (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd, size_t wm_size) { - ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE>::water_marks"); + ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE, TIME_POLICY>::water_marks"); if (cmd == ACE_IO_Cntl_Msg::SET_LWM) this->msg_queue_->low_water_mark (wm_size); else /* cmd == ACE_IO_Cntl_Msg::SET_HWM */ this->msg_queue_->high_water_mark (wm_size); } -template <ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE> ACE_INLINE int -ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE>::getq (ACE_MESSAGE_TYPE *&mb, ACE_Time_Value *tv) +template <ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE, class TIME_POLICY> ACE_INLINE int +ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE, TIME_POLICY>::getq (ACE_MESSAGE_TYPE *&mb, ACE_Time_Value *tv) { - ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE>::getq"); + ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE, TIME_POLICY>::getq"); return this->msg_queue_->dequeue_head (mb, tv); } -template <ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE> ACE_INLINE int -ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE>::putq (ACE_MESSAGE_TYPE *mb, ACE_Time_Value *tv) +template <ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE, class TIME_POLICY> ACE_INLINE int +ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE, TIME_POLICY>::putq (ACE_MESSAGE_TYPE *mb, ACE_Time_Value *tv) { - ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE>::putq"); + ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE, TIME_POLICY>::putq"); return this->msg_queue_->enqueue_tail (mb, tv); } -template <ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE> ACE_INLINE int -ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE>::ungetq (ACE_MESSAGE_TYPE *mb, ACE_Time_Value *tv) +template <ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE, class TIME_POLICY> ACE_INLINE int +ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE, TIME_POLICY>::ungetq (ACE_MESSAGE_TYPE *mb, ACE_Time_Value *tv) { - ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE>::ungetq"); + ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE, TIME_POLICY>::ungetq"); return this->msg_queue_->enqueue_head (mb, tv); } -template <ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE> ACE_INLINE int -ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE>::flush (u_long flag) +template <ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE, class TIME_POLICY> ACE_INLINE int +ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE, TIME_POLICY>::flush (u_long flag) { - ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE>::flush"); + ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE, TIME_POLICY>::flush"); if (ACE_BIT_ENABLED (flag, ACE_Task_Flags::ACE_FLUSHALL)) return this->msg_queue_ != 0 && this->msg_queue_->close (); else return -1; // Note, need to be more careful about what we free... } -template <ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE> ACE_INLINE void -ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE>::msg_queue (ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE> *mq) +template <ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE, class TIME_POLICY> ACE_INLINE void +ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE, TIME_POLICY>::msg_queue (ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY> *mq) { - ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE>::msg_queue"); + ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE, TIME_POLICY>::msg_queue"); if (this->delete_msg_queue_) { delete this->msg_queue_; @@ -58,44 +58,44 @@ ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE>::msg_queue (ACE_Message_Queue_Ex<ACE this->msg_queue_ = mq; } -template <ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE> ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE> * -ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE>::msg_queue (void) +template <ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE, class TIME_POLICY> ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY> * +ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE, TIME_POLICY>::msg_queue (void) { - ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE>::msg_queue"); + ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE, TIME_POLICY>::msg_queue"); return this->msg_queue_; } -template <ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE> ACE_INLINE int -ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE>::reply (ACE_MESSAGE_TYPE *mb, ACE_Time_Value *tv) +template <ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE, class TIME_POLICY> ACE_INLINE int +ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE, TIME_POLICY>::reply (ACE_MESSAGE_TYPE *mb, ACE_Time_Value *tv) { - ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE>::reply"); + ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE, TIME_POLICY>::reply"); ACE_UNUSED_ARG (mb); ACE_UNUSED_ARG (tv); return -1 ; // this->sibling ()->put_next (mb, tv); } -template <ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE> ACE_INLINE ACE_Task<ACE_SYNCH_USE> * -ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE>::next (void) +template <ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE, class TIME_POLICY> ACE_INLINE ACE_Task<ACE_SYNCH_USE, TIME_POLICY> * +ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE, TIME_POLICY>::next (void) { - ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE>::next"); + ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE, TIME_POLICY>::next"); return this->next_; } -template <ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE> ACE_INLINE void -ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE>::next (ACE_Task<ACE_SYNCH_USE> *q) +template <ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE, class TIME_POLICY> ACE_INLINE void +ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE, TIME_POLICY>::next (ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *q) { - ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE>::next"); + ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE, TIME_POLICY>::next"); this->next_ = q; } // Transfer msg to the next ACE_Task_Ex. -template <ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE> ACE_INLINE int -ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE>::put_next ( +template <ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE, class TIME_POLICY> ACE_INLINE int +ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE, TIME_POLICY>::put_next ( ACE_MESSAGE_TYPE * /* msg */, ACE_Time_Value * /* tv */) { - ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE>::put_next"); + ACE_TRACE ("ACE_Task_Ex<ACE_SYNCH_USE,ACE_MESSAGE_TYPE, TIME_POLICY>::put_next"); return -1; // this->next_ == 0 ? -1 : this->next_->put (msg, tv); } diff --git a/ACE/ace/Task_T.cpp b/ACE/ace/Task_T.cpp index cb7010d0bda..9ec0def8a34 100644 --- a/ACE/ace/Task_T.cpp +++ b/ACE/ace/Task_T.cpp @@ -18,11 +18,11 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -template <ACE_SYNCH_DECL> void -ACE_Task<ACE_SYNCH_USE>::dump (void) const +template <ACE_SYNCH_DECL, class TIME_POLICY> void +ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::dump (void) const { #if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Task<ACE_SYNCH_USE>::dump"); + ACE_TRACE ("ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nthr_mgr_ = %x"), this->thr_mgr_)); this->msg_queue_->dump (); @@ -43,31 +43,32 @@ ACE_Task<ACE_SYNCH_USE>::dump (void) const // If the user doesn't supply a ACE_Message_Queue pointer then we'll // allocate one dynamically. Otherwise, we'll use the one they give. -template<ACE_SYNCH_DECL> -ACE_Task<ACE_SYNCH_USE>::ACE_Task (ACE_Thread_Manager *thr_man, - ACE_Message_Queue<ACE_SYNCH_USE> *mq) +template<ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::ACE_Task (ACE_Thread_Manager *thr_man, + ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY> *mq) : ACE_Task_Base (thr_man), msg_queue_ (0), delete_msg_queue_ (false), mod_ (0), next_ (0) { - ACE_TRACE ("ACE_Task<ACE_SYNCH_USE>::ACE_Task"); + ACE_TRACE ("ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::ACE_Task"); if (mq == 0) { + typedef ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY> QUEUE_TYPE; ACE_NEW (mq, - ACE_Message_Queue<ACE_SYNCH_USE>); + QUEUE_TYPE); this->delete_msg_queue_ = true; } this->msg_queue_ = mq; } -template<ACE_SYNCH_DECL> -ACE_Task<ACE_SYNCH_USE>::~ACE_Task (void) +template<ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::~ACE_Task (void) { - ACE_TRACE ("ACE_Task<ACE_SYNCH_USE>::~ACE_Task"); + ACE_TRACE ("ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::~ACE_Task"); if (this->delete_msg_queue_) delete this->msg_queue_; @@ -76,30 +77,30 @@ ACE_Task<ACE_SYNCH_USE>::~ACE_Task (void) this->delete_msg_queue_ = false; } -template<ACE_SYNCH_DECL> ACE_Task<ACE_SYNCH_USE> * -ACE_Task<ACE_SYNCH_USE>::sibling (void) +template<ACE_SYNCH_DECL, class TIME_POLICY> ACE_Task<ACE_SYNCH_USE, TIME_POLICY> * +ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::sibling (void) { - ACE_TRACE ("ACE_Task<ACE_SYNCH_USE>::sibling"); + ACE_TRACE ("ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::sibling"); if (this->mod_ == 0) return 0; else return this->mod_->sibling (this); } -template<ACE_SYNCH_DECL> const ACE_TCHAR * -ACE_Task<ACE_SYNCH_USE>::name (void) const +template<ACE_SYNCH_DECL, class TIME_POLICY> const ACE_TCHAR * +ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::name (void) const { - ACE_TRACE ("ACE_Task<ACE_SYNCH_USE>::name"); + ACE_TRACE ("ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::name"); if (this->mod_ == 0) return 0; else return this->mod_->name (); } -template<ACE_SYNCH_DECL> ACE_Module<ACE_SYNCH_USE> * -ACE_Task<ACE_SYNCH_USE>::module (void) const +template<ACE_SYNCH_DECL, class TIME_POLICY> ACE_Module<ACE_SYNCH_USE, TIME_POLICY> * +ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::module (void) const { - ACE_TRACE ("ACE_Task<ACE_SYNCH_USE>::module"); + ACE_TRACE ("ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::module"); return this->mod_; } diff --git a/ACE/ace/Task_T.h b/ACE/ace/Task_T.h index c5cf0606f5e..d3823345665 100644 --- a/ACE/ace/Task_T.h +++ b/ACE/ace/Task_T.h @@ -27,7 +27,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL // Forward decls... -template <ACE_SYNCH_DECL> class ACE_Module; +template <ACE_SYNCH_DECL, class TIME_POLICY> class ACE_Module; /** * @class ACE_Task @@ -38,11 +38,11 @@ template <ACE_SYNCH_DECL> class ACE_Module; * This class serves as the basis for passive and active objects * in ACE. */ -template <ACE_SYNCH_DECL> +template <ACE_SYNCH_DECL, class TIME_POLICY = ACE_System_Time_Policy> class ACE_Task : public ACE_Task_Base { public: - friend class ACE_Module<ACE_SYNCH_USE>; + friend class ACE_Module<ACE_SYNCH_USE, TIME_POLICY>; friend class ACE_Module_Type; // = Initialization/termination methods. @@ -53,16 +53,24 @@ public: * one passed as a parameter. */ ACE_Task (ACE_Thread_Manager *thr_mgr = 0, - ACE_Message_Queue<ACE_SYNCH_USE> *mq = 0); + ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY> *mq = 0); /// Destructor. virtual ~ACE_Task (void); /// Gets the message queue associated with this task. - ACE_Message_Queue<ACE_SYNCH_USE> *msg_queue (void); + ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY> *msg_queue (void); /// Sets the message queue associated with this task. - void msg_queue (ACE_Message_Queue<ACE_SYNCH_USE> *); + void msg_queue (ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY> *); + + /// Get the current time of day according to the queue's TIME_POLICY. + /// Allows users to initialize timeout values using correct time policy. + ACE_Time_Value_T<TIME_POLICY> gettimeofday (void) const; + + /// Allows applications to control how the timer queue gets the time + /// of day. + void set_time_policy (TIME_POLICY const & time_policy); public: // Should be protected: // = Message queue manipulation methods. @@ -118,17 +126,17 @@ public: // Should be protected: // = Pointers to next ACE_Task_Base (if ACE is part of an ACE_Stream). /// Get next Task pointer. - ACE_Task<ACE_SYNCH_USE> *next (void); + ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *next (void); /// Set next Task pointer. - void next (ACE_Task<ACE_SYNCH_USE> *); + void next (ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *); /// Return the Task's sibling if there's one associated with the /// Task's Module, else returns 0. - ACE_Task<ACE_SYNCH_USE> *sibling (void); + ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *sibling (void); /// Return the Task's Module if there is one, else returns 0. - ACE_Module<ACE_SYNCH_USE> *module (void) const; + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *module (void) const; /** * Flush the task's queue, i.e., free all of the enqueued @@ -144,16 +152,16 @@ public: // Should be protected: void water_marks (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds, size_t); /// Queue of messages on the ACE_Task.. - ACE_Message_Queue<ACE_SYNCH_USE> *msg_queue_; + ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY> *msg_queue_; /// true if should delete Message_Queue, false otherwise. bool delete_msg_queue_; /// Back-pointer to the enclosing module. - ACE_Module<ACE_SYNCH_USE> *mod_; + ACE_Module<ACE_SYNCH_USE, TIME_POLICY> *mod_; /// Pointer to adjacent ACE_Task. - ACE_Task<ACE_SYNCH_USE> *next_; + ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *next_; /// Dump the state of an object. void dump (void) const; @@ -164,8 +172,8 @@ public: // Should be protected: private: // = Disallow these operations. - ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Task<ACE_SYNCH_USE> &)) - ACE_UNIMPLEMENTED_FUNC (ACE_Task (const ACE_Task<ACE_SYNCH_USE> &)) + ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Task<ACE_SYNCH_USE, TIME_POLICY> &)) + ACE_UNIMPLEMENTED_FUNC (ACE_Task (const ACE_Task<ACE_SYNCH_USE, TIME_POLICY> &)) }; #if defined ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION_EXPORT diff --git a/ACE/ace/Task_T.inl b/ACE/ace/Task_T.inl index adfef98cb03..c9b076f497c 100644 --- a/ACE/ace/Task_T.inl +++ b/ACE/ace/Task_T.inl @@ -4,52 +4,52 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -template <ACE_SYNCH_DECL> ACE_INLINE void -ACE_Task<ACE_SYNCH_USE>::water_marks (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd, +template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_INLINE void +ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::water_marks (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd, size_t wm_size) { - ACE_TRACE ("ACE_Task<ACE_SYNCH_USE>::water_marks"); + ACE_TRACE ("ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::water_marks"); if (cmd == ACE_IO_Cntl_Msg::SET_LWM) this->msg_queue_->low_water_mark (wm_size); else /* cmd == ACE_IO_Cntl_Msg::SET_HWM */ this->msg_queue_->high_water_mark (wm_size); } -template <ACE_SYNCH_DECL> ACE_INLINE int -ACE_Task<ACE_SYNCH_USE>::getq (ACE_Message_Block *&mb, ACE_Time_Value *tv) +template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_INLINE int +ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::getq (ACE_Message_Block *&mb, ACE_Time_Value *tv) { - ACE_TRACE ("ACE_Task<ACE_SYNCH_USE>::getq"); + ACE_TRACE ("ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::getq"); return this->msg_queue_->dequeue_head (mb, tv); } -template <ACE_SYNCH_DECL> ACE_INLINE int -ACE_Task<ACE_SYNCH_USE>::putq (ACE_Message_Block *mb, ACE_Time_Value *tv) +template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_INLINE int +ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::putq (ACE_Message_Block *mb, ACE_Time_Value *tv) { - ACE_TRACE ("ACE_Task<ACE_SYNCH_USE>::putq"); + ACE_TRACE ("ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::putq"); return this->msg_queue_->enqueue_tail (mb, tv); } -template <ACE_SYNCH_DECL> ACE_INLINE int -ACE_Task<ACE_SYNCH_USE>::ungetq (ACE_Message_Block *mb, ACE_Time_Value *tv) +template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_INLINE int +ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::ungetq (ACE_Message_Block *mb, ACE_Time_Value *tv) { - ACE_TRACE ("ACE_Task<ACE_SYNCH_USE>::ungetq"); + ACE_TRACE ("ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::ungetq"); return this->msg_queue_->enqueue_head (mb, tv); } -template <ACE_SYNCH_DECL> ACE_INLINE int -ACE_Task<ACE_SYNCH_USE>::flush (u_long flag) +template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_INLINE int +ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::flush (u_long flag) { - ACE_TRACE ("ACE_Task<ACE_SYNCH_USE>::flush"); + ACE_TRACE ("ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::flush"); if (ACE_BIT_ENABLED (flag, ACE_Task_Flags::ACE_FLUSHALL)) return this->msg_queue_ != 0 && this->msg_queue_->close (); else return -1; // Note, need to be more careful about what we free... } -template <ACE_SYNCH_DECL> ACE_INLINE void -ACE_Task<ACE_SYNCH_USE>::msg_queue (ACE_Message_Queue<ACE_SYNCH_USE> *mq) +template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_INLINE void +ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::msg_queue (ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY> *mq) { - ACE_TRACE ("ACE_Task<ACE_SYNCH_USE>::msg_queue"); + ACE_TRACE ("ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::msg_queue"); if (this->delete_msg_queue_) { delete this->msg_queue_; @@ -58,40 +58,58 @@ ACE_Task<ACE_SYNCH_USE>::msg_queue (ACE_Message_Queue<ACE_SYNCH_USE> *mq) this->msg_queue_ = mq; } -template <ACE_SYNCH_DECL> ACE_Message_Queue<ACE_SYNCH_USE> * -ACE_Task<ACE_SYNCH_USE>::msg_queue (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY> * +ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::msg_queue (void) { - ACE_TRACE ("ACE_Task<ACE_SYNCH_USE>::msg_queue"); + ACE_TRACE ("ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::msg_queue"); return this->msg_queue_; } -template <ACE_SYNCH_DECL> ACE_INLINE int -ACE_Task<ACE_SYNCH_USE>::reply (ACE_Message_Block *mb, ACE_Time_Value *tv) +template <ACE_SYNCH_DECL, class TIME_POLICY> +ACE_Time_Value_T<TIME_POLICY> +ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::gettimeofday (void) const { - ACE_TRACE ("ACE_Task<ACE_SYNCH_USE>::reply"); + if (this->msg_queue_ != 0) + return this->msg_queue_->gettimeofday (); + + return ACE_Time_Value_T<TIME_POLICY> (ACE_Time_Value::zero); +} + +template <ACE_SYNCH_DECL, class TIME_POLICY> +void +ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::set_time_policy (TIME_POLICY const & rhs) +{ + if (this->msg_queue_ != 0) + this->msg_queue_->set_time_policy (rhs); +} + +template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_INLINE int +ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::reply (ACE_Message_Block *mb, ACE_Time_Value *tv) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::reply"); return this->sibling ()->put_next (mb, tv); } -template <ACE_SYNCH_DECL> ACE_INLINE ACE_Task<ACE_SYNCH_USE> * -ACE_Task<ACE_SYNCH_USE>::next (void) +template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_INLINE ACE_Task<ACE_SYNCH_USE, TIME_POLICY> * +ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::next (void) { - ACE_TRACE ("ACE_Task<ACE_SYNCH_USE>::next"); + ACE_TRACE ("ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::next"); return this->next_; } -template <ACE_SYNCH_DECL> ACE_INLINE void -ACE_Task<ACE_SYNCH_USE>::next (ACE_Task<ACE_SYNCH_USE> *q) +template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_INLINE void +ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::next (ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *q) { - ACE_TRACE ("ACE_Task<ACE_SYNCH_USE>::next"); + ACE_TRACE ("ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::next"); this->next_ = q; } // Transfer msg to the next ACE_Task. -template <ACE_SYNCH_DECL> ACE_INLINE int -ACE_Task<ACE_SYNCH_USE>::put_next (ACE_Message_Block *msg, ACE_Time_Value *tv) +template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_INLINE int +ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::put_next (ACE_Message_Block *msg, ACE_Time_Value *tv) { - ACE_TRACE ("ACE_Task<ACE_SYNCH_USE>::put_next"); + ACE_TRACE ("ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::put_next"); return this->next_ == 0 ? -1 : this->next_->put (msg, tv); } diff --git a/ACE/ace/Thread_Manager.cpp b/ACE/ace/Thread_Manager.cpp index fcbd4486481..193add0fa9d 100644 --- a/ACE/ace/Thread_Manager.cpp +++ b/ACE/ace/Thread_Manager.cpp @@ -374,6 +374,22 @@ ACE_Thread_Manager::ACE_Thread_Manager (size_t prealloc, ACE_TRACE ("ACE_Thread_Manager::ACE_Thread_Manager"); } +ACE_Thread_Manager::ACE_Thread_Manager (const ACE_Condition_Attributes &attributes, + size_t prealloc, + size_t lwm, + size_t inc, + size_t hwm) + : grp_id_ (1), + automatic_wait_ (1) +#if defined (ACE_HAS_THREADS) + , zero_cond_ (lock_, attributes) +#endif /* ACE_HAS_THREADS */ + , thread_desc_freelist_ (ACE_FREE_LIST_WITH_POOL, + prealloc, lwm, hwm, inc) +{ + ACE_TRACE ("ACE_Thread_Manager::ACE_Thread_Manager"); +} + #if ! defined (ACE_THREAD_MANAGER_LACKS_STATICS) ACE_Thread_Manager * ACE_Thread_Manager::instance (void) @@ -1608,13 +1624,16 @@ ACE_Thread_Manager::wait (const ACE_Time_Value *timeout, { ACE_TRACE ("ACE_Thread_Manager::wait"); - ACE_Time_Value local_timeout; + ACE_Auto_Ptr<ACE_Time_Value> local_timeout; // Check to see if we're using absolute time or not. if (use_absolute_time == false && timeout != 0) { - local_timeout = *timeout; - local_timeout += ACE_OS::gettimeofday (); - timeout = &local_timeout; + // create time value duplicate (preserves time policy) + local_timeout.reset (timeout->duplicate ()); + // convert time value to absolute time + (*local_timeout) = local_timeout->to_absolute_time (); + // replace original time by abs time duplicate + timeout = local_timeout.get (); } #if !defined (ACE_HAS_VXTHREADS) diff --git a/ACE/ace/Thread_Manager.h b/ACE/ace/Thread_Manager.h index 1b2c18ee0e2..7d2fb6f197e 100644 --- a/ACE/ace/Thread_Manager.h +++ b/ACE/ace/Thread_Manager.h @@ -437,6 +437,11 @@ public: size_t lwm = ACE_DEFAULT_THREAD_MANAGER_LWM, size_t inc = ACE_DEFAULT_THREAD_MANAGER_INC, size_t hwm = ACE_DEFAULT_THREAD_MANAGER_HWM); + ACE_Thread_Manager (const ACE_Condition_Attributes &attributes, + size_t preaolloc = ACE_DEFAULT_THREAD_MANAGER_PREALLOC, + size_t lwm = ACE_DEFAULT_THREAD_MANAGER_LWM, + size_t inc = ACE_DEFAULT_THREAD_MANAGER_INC, + size_t hwm = ACE_DEFAULT_THREAD_MANAGER_HWM); ~ACE_Thread_Manager (void); #if ! defined (ACE_THREAD_MANAGER_LACKS_STATICS) diff --git a/ACE/ace/Thread_Mutex.h b/ACE/ace/Thread_Mutex.h index 09d2474e3bd..5481e8db920 100644 --- a/ACE/ace/Thread_Mutex.h +++ b/ACE/ace/Thread_Mutex.h @@ -49,7 +49,6 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL */ class ACE_Export ACE_Thread_Mutex { - friend class ACE_Condition_Thread_Mutex; public: /// Constructor. ACE_Thread_Mutex (const ACE_TCHAR *name = 0, diff --git a/ACE/ace/Time_Policy.cpp b/ACE/ace/Time_Policy.cpp index 4e36ffe6734..f87445c89fc 100644 --- a/ACE/ace/Time_Policy.cpp +++ b/ACE/ace/Time_Policy.cpp @@ -12,12 +12,23 @@ ACE_Dynamic_Time_Policy_Base::~ACE_Dynamic_Time_Policy_Base () { } -ACE_Time_Value ACE_Delegating_Time_Policy::NULL_Time_Policy::gettimeofday () const + +class NULL_Time_Policy : public ACE_Dynamic_Time_Policy_Base +{ +protected: + virtual ACE_Time_Value_T<ACE_Delegating_Time_Policy> gettimeofday () const; +}; + +ACE_Time_Value_T<ACE_Delegating_Time_Policy> NULL_Time_Policy::gettimeofday () const { - return ACE_Time_Value::zero; + return ACE_Time_Value_T<ACE_Delegating_Time_Policy> (ACE_Time_Value::zero); } -ACE_Delegating_Time_Policy::NULL_Time_Policy ACE_Delegating_Time_Policy::null_policy_; +static NULL_Time_Policy null_policy_; -ACE_END_VERSIONED_NAMESPACE_DECL +ACE_Delegating_Time_Policy::ACE_Delegating_Time_Policy (ACE_Dynamic_Time_Policy_Base const * delegate) + : delegate_ (delegate != 0 ? delegate : &null_policy_) +{ +} +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Time_Policy.h b/ACE/ace/Time_Policy.h index d8704033e5d..9f258efc57d 100644 --- a/ACE/ace/Time_Policy.h +++ b/ACE/ace/Time_Policy.h @@ -13,7 +13,7 @@ #include /**/ "ace/config-all.h" -#include /**/ "ace/Time_Value.h" +#include /**/ "ace/Time_Value_T.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once @@ -34,7 +34,7 @@ class ACE_Export ACE_System_Time_Policy { public: /// Return the current time according to this policy - ACE_Time_Value operator() () const; + ACE_Time_Value_T<ACE_System_Time_Policy> operator() () const; /// Noop. Just here to satisfy backwards compatibility demands. void set_gettimeofday (ACE_Time_Value (*gettimeofday)(void)); @@ -50,7 +50,7 @@ class ACE_Export ACE_HR_Time_Policy { public: /// Return the current time according to this policy - ACE_Time_Value operator() () const; + ACE_Time_Value_T<ACE_HR_Time_Policy> operator() () const; /// Noop. Just here to satisfy backwards compatibility demands. void set_gettimeofday (ACE_Time_Value (*gettimeofday)(void)); @@ -92,7 +92,7 @@ public: ACE_FPointer_Time_Policy(FPtr f); /// Return the current time according to this policy - ACE_Time_Value operator()() const; + ACE_Time_Value_T<ACE_FPointer_Time_Policy> operator()() const; /// Satisfy backwards compatibility demands. void set_gettimeofday (ACE_Time_Value (*gettimeofday)(void)); @@ -100,27 +100,7 @@ private: FPtr function_; }; -/** - * @class ACE_Dynamic_Time_Policy_base - * - * @brief Abstract base class for dynamically loaded and/or shared - * time policies. - * - */ -class ACE_Export ACE_Dynamic_Time_Policy_Base -{ -public: - virtual ~ACE_Dynamic_Time_Policy_Base (); - - /// 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; -}; +class ACE_Dynamic_Time_Policy_Base; // forward decl /** * @class ACE_Delegating_Time_Policy @@ -134,7 +114,7 @@ public: ACE_Delegating_Time_Policy (ACE_Dynamic_Time_Policy_Base const * delegate = 0); /// Return the current time according to this policy - ACE_Time_Value operator()() const; + ACE_Time_Value_T<ACE_Delegating_Time_Policy> operator()() const; /// Set delegate void set_delegate (ACE_Dynamic_Time_Policy_Base const * delegate); @@ -146,14 +126,28 @@ public: void set_gettimeofday (ACE_Time_Value (*gettimeofday)(void)); private: ACE_Dynamic_Time_Policy_Base const * delegate_; +}; - class NULL_Time_Policy : public ACE_Dynamic_Time_Policy_Base - { - protected: - virtual ACE_Time_Value gettimeofday () const; - }; +/** + * @class ACE_Dynamic_Time_Policy_base + * + * @brief Abstract base class for dynamically loaded and/or shared + * time policies. + * + */ +class ACE_Export ACE_Dynamic_Time_Policy_Base +{ +public: + virtual ~ACE_Dynamic_Time_Policy_Base (); - static NULL_Time_Policy null_policy_; + /// Return the current time according to this policy + ACE_Time_Value_T<ACE_Delegating_Time_Policy> 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_T<ACE_Delegating_Time_Policy> gettimeofday () const = 0; }; /// Temporarily, for backwards compatibility reasons, this will @@ -161,6 +155,13 @@ private: /// ACE_System_Time_Policy. typedef ACE_FPointer_Time_Policy ACE_Default_Time_Policy; +#if defined ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION_EXPORT +template class ACE_Export ACE_Time_Value_T<ACE_System_Time_Policy>; +template class ACE_Export ACE_Time_Value_T<ACE_HR_Time_Policy>; +template class ACE_Export ACE_Time_Value_T<ACE_FPointer_Time_Policy>; +template class ACE_Export ACE_Time_Value_T<ACE_Delegating_Time_Policy>; +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION_EXPORT */ + ACE_END_VERSIONED_NAMESPACE_DECL #if defined (__ACE_INLINE__) diff --git a/ACE/ace/Time_Policy.inl b/ACE/ace/Time_Policy.inl index 19fd9c6c206..1ff177dc005 100644 --- a/ACE/ace/Time_Policy.inl +++ b/ACE/ace/Time_Policy.inl @@ -7,10 +7,10 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -ACE_INLINE ACE_Time_Value +ACE_INLINE ACE_Time_Value_T<ACE_System_Time_Policy> ACE_System_Time_Policy::operator()() const { - return ACE_OS::gettimeofday(); + return ACE_Time_Value_T<ACE_System_Time_Policy> (ACE_OS::gettimeofday()); } ACE_INLINE void @@ -18,10 +18,10 @@ ACE_System_Time_Policy::set_gettimeofday (ACE_Time_Value (*)(void)) { } -ACE_INLINE ACE_Time_Value +ACE_INLINE ACE_Time_Value_T<ACE_HR_Time_Policy> ACE_HR_Time_Policy::operator()() const { - return ACE_High_Res_Timer::gettimeofday_hr (); + return ACE_Time_Value_T<ACE_HR_Time_Policy> (ACE_High_Res_Timer::gettimeofday_hr ()); } ACE_INLINE void @@ -42,10 +42,10 @@ ACE_FPointer_Time_Policy(ACE_FPointer_Time_Policy::FPtr f) { } -ACE_INLINE ACE_Time_Value +ACE_INLINE ACE_Time_Value_T<ACE_FPointer_Time_Policy> ACE_FPointer_Time_Policy::operator()() const { - return (*this->function_)(); + return ACE_Time_Value_T<ACE_FPointer_Time_Policy> ((*this->function_)(), *this); } ACE_INLINE void @@ -54,7 +54,7 @@ ACE_FPointer_Time_Policy::set_gettimeofday (ACE_Time_Value (*f)(void)) this->function_ = f; } -ACE_INLINE ACE_Time_Value +ACE_INLINE ACE_Time_Value_T<ACE_Delegating_Time_Policy> ACE_Dynamic_Time_Policy_Base::operator()() const { return this->gettimeofday (); @@ -65,13 +65,7 @@ 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_) -{ -} - -ACE_INLINE ACE_Time_Value +ACE_INLINE ACE_Time_Value_T<ACE_Delegating_Time_Policy> ACE_Delegating_Time_Policy::operator()() const { return (*this->delegate_) (); diff --git a/ACE/ace/Time_Policy_T.cpp b/ACE/ace/Time_Policy_T.cpp index f2a75aea684..ab31f4932c3 100644 --- a/ACE/ace/Time_Policy_T.cpp +++ b/ACE/ace/Time_Policy_T.cpp @@ -11,15 +11,15 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -template <typename TIME_POLICY> ACE_INLINE +template <typename TIME_POLICY> ACE_Time_Policy_T<TIME_POLICY>::~ACE_Time_Policy_T () { } -template <typename TIME_POLICY> ACE_INLINE ACE_Time_Value +template <typename TIME_POLICY> ACE_Time_Value_T<ACE_Delegating_Time_Policy> ACE_Time_Policy_T<TIME_POLICY>::gettimeofday () const { - return this->time_policy_ (); + return ACE_Time_Value_T<ACE_Delegating_Time_Policy> (this->time_policy_ (), ACE_Delegating_Time_Policy (this)); } ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Time_Policy_T.h b/ACE/ace/Time_Policy_T.h index e91eccaa468..687a1fae2a4 100644 --- a/ACE/ace/Time_Policy_T.h +++ b/ACE/ace/Time_Policy_T.h @@ -40,7 +40,7 @@ public: virtual ~ACE_Time_Policy_T (); /// Return the current time according to this policy - ACE_Time_Value operator()() const; + ACE_Time_Value_T<ACE_Delegating_Time_Policy> operator()() const; /// Allows applications to control how the timer queue gets the time /// of day. @@ -50,7 +50,7 @@ public: void set_gettimeofday (ACE_Time_Value (*gettimeofday)(void)); protected: /// Return the current time according to policy implementation. - virtual ACE_Time_Value gettimeofday () const; + virtual ACE_Time_Value_T<ACE_Delegating_Time_Policy> gettimeofday () const; private: /// The policy to return the current time of day diff --git a/ACE/ace/Time_Policy_T.inl b/ACE/ace/Time_Policy_T.inl index 4d30d6c6fc5..c33b102c7e6 100644 --- a/ACE/ace/Time_Policy_T.inl +++ b/ACE/ace/Time_Policy_T.inl @@ -4,13 +4,15 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL -template <typename TIME_POLICY> ACE_INLINE +template <typename TIME_POLICY> +ACE_INLINE ACE_Time_Policy_T<TIME_POLICY>::ACE_Time_Policy_T (TIME_POLICY const & time_policy) : time_policy_ (time_policy) { } -template <typename TIME_POLICY> ACE_INLINE ACE_Time_Value +template <typename TIME_POLICY> +ACE_INLINE ACE_Time_Value_T<ACE_Delegating_Time_Policy> ACE_Time_Policy_T<TIME_POLICY>::operator() () const { return this->gettimeofday (); diff --git a/ACE/ace/Time_Value.cpp b/ACE/ace/Time_Value.cpp index 1cb25d46664..a3abe1675d6 100644 --- a/ACE/ace/Time_Value.cpp +++ b/ACE/ace/Time_Value.cpp @@ -9,6 +9,7 @@ #include "ace/Numeric_Limits.h" #include "ace/If_Then_Else.h" #include "ace/OS_NS_math.h" +#include "ace/Time_Policy.h" #ifdef ACE_HAS_CPP98_IOSTREAMS #include <ostream> @@ -33,6 +34,9 @@ const ACE_Time_Value ACE_Time_Value::max_time ( ACE_ALLOC_HOOK_DEFINE (ACE_Time_Value) +ACE_Time_Value::~ACE_Time_Value() +{} + /// Increment microseconds (the only reason this is here is to allow /// the use of ACE_Atomic_Op with ACE_Time_Value). ACE_Time_Value @@ -127,6 +131,35 @@ ACE_Time_Value::operator FILETIME () const } #endif /* ACE_WIN32 */ +ACE_Time_Value +ACE_Time_Value::now () const +{ + ACE_System_Time_Policy systp; + return systp (); +} + +ACE_Time_Value +ACE_Time_Value::to_relative_time () const +{ + ACE_System_Time_Policy systp; + return (*this) - systp (); +} + +ACE_Time_Value +ACE_Time_Value::to_absolute_time () const +{ + ACE_System_Time_Policy systp; + return (*this) + systp (); +} + +ACE_Time_Value * +ACE_Time_Value::duplicate () const +{ + ACE_Time_Value * tmp = 0; + ACE_NEW_RETURN (tmp, ACE_Time_Value (*this), 0); + return tmp; +} + void ACE_Time_Value::dump (void) const { diff --git a/ACE/ace/Time_Value.h b/ACE/ace/Time_Value.h index a0f76dfefed..ef02611ce0a 100644 --- a/ACE/ace/Time_Value.h +++ b/ACE/ace/Time_Value.h @@ -80,6 +80,9 @@ public: /// Construct the ACE_Time_Value object from a timespec_t. explicit ACE_Time_Value (const timespec_t &t); + /// Destructor + virtual ~ACE_Time_Value (); + # if defined (ACE_WIN32) /// Construct the ACE_Time_Value object from a Win32 FILETIME explicit ACE_Time_Value (const FILETIME &ft); @@ -320,6 +323,51 @@ public: double d); //@} + /// Get current time of day. + /** + * @return Time value representing current time of day. + * + * @note This method is overloaded in the time policy based template + * instantiations derived from this class. Allows for time policy + * aware time values. + */ + virtual ACE_Time_Value now () const; + + /// Converts absolute time value to time value relative to current time of day. + /** + * @return Relative time value. + * + * @note This method is overloaded in the time policy based template + * instantiations derived from this class. Allows for time policy + * aware time values. + * The developer is responsible for making sure this is an absolute + * time value compatible with the active time policy (which is system + * time for the base class). + */ + virtual ACE_Time_Value to_relative_time () const; + + /// Converts relative time value to absolute time value based on current time of day. + /** + * @return Absolute time value. + * + * @note This method is overloaded in the time policy based template + * instantiations derived from this class. Allows for time policy + * aware time values. + * The developer is responsible for making sure this is a relative + * time value. Current time of day is determined based on time policy + * (which is system time for the base class). + */ + virtual ACE_Time_Value to_absolute_time () const; + + /// Duplicates this time value (incl. time policy). + /** + * @return Dynamically allocated time value copy. + * + * @note The caller is responsible for freeing the copy when it's not needed + * anymore. + */ + virtual ACE_Time_Value * duplicate () const; + /// Dump is a no-op. /** * The dump() method is a no-op. It's here for backwards compatibility diff --git a/ACE/ace/Time_Value_T.cpp b/ACE/ace/Time_Value_T.cpp new file mode 100644 index 00000000000..0968b43155d --- /dev/null +++ b/ACE/ace/Time_Value_T.cpp @@ -0,0 +1,52 @@ +// $Id$ + +#ifndef ACE_TIME_VALUE_T_CPP +#define ACE_TIME_VALUE_T_CPP + +#include "ace/Time_Value_T.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (__ACE_INLINE__) +#include "ace/Time_Value_T.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/OS_Memory.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template <class TIME_POLICY> +ACE_Time_Value +ACE_Time_Value_T<TIME_POLICY>::now () const +{ + return this->time_policy_ (); +} + +template <class TIME_POLICY> +ACE_Time_Value +ACE_Time_Value_T<TIME_POLICY>::to_relative_time () const +{ + return (*this) - this->time_policy_ (); +} + +template <class TIME_POLICY> +ACE_Time_Value +ACE_Time_Value_T<TIME_POLICY>::to_absolute_time () const +{ + return (*this) + this->time_policy_ (); +} + +template <class TIME_POLICY> +ACE_Time_Value * +ACE_Time_Value_T<TIME_POLICY>::duplicate () const +{ + ACE_Time_Value_T<TIME_POLICY> * tmp = 0; + ACE_NEW_RETURN (tmp, ACE_Time_Value_T<TIME_POLICY> (*this), 0); + return tmp; +} + +ACE_END_VERSIONED_NAMESPACE_DECL + +#endif /* ACE_TIME_VALUE_T_CPP */ diff --git a/ACE/ace/Time_Value_T.h b/ACE/ace/Time_Value_T.h new file mode 100644 index 00000000000..b26ee0bb3c5 --- /dev/null +++ b/ACE/ace/Time_Value_T.h @@ -0,0 +1,194 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Time_Value_T.h + * + * $Id$ + * + * @author Martin Corino <mcorino@remedy.nl> + */ +//============================================================================= + +#ifndef ACE_TIME_VALUE_T_H +#define ACE_TIME_VALUE_T_H + +#include /**/ "ace/pre.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Time_Value.h" + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class ACE_Time_Value + * + * @brief Operations on "timeval" structures, which express time in + * seconds (secs) and microseconds (usecs). + * + * This class centralizes all the time related processing in + * ACE. These time values are typically used in conjunction with OS + * mechanisms like <select>, <poll>, or <cond_timedwait>. + */ +template <class TIME_POLICY> +class ACE_Time_Value_T : public ACE_Time_Value +{ +public: + typedef TIME_POLICY time_policy_t; + + // = Initialization methods. + + /// Default Constructor. + ACE_Time_Value_T (void) {} + + /// Constructor. + explicit ACE_Time_Value_T (time_t sec, suseconds_t usec = 0) + : ACE_Time_Value (sec, usec) {} + + // = Methods for converting to/from various time formats. + + /// Construct the ACE_Time_Value from a timeval. + explicit ACE_Time_Value_T (const struct timeval &t) + : ACE_Time_Value (t) {} + + /// Construct the ACE_Time_Value object from a timespec_t. + explicit ACE_Time_Value_T (const timespec_t &t) + : ACE_Time_Value (t) {} + + /// Construct from ACE_Time_Value_T<TIME_POLICY> + ACE_Time_Value_T(const ACE_Time_Value_T<TIME_POLICY>& tv) + : ACE_Time_Value (tv), + time_policy_ (tv.time_policy_) + {} + + /// Construct from ACE_Time_Value + explicit ACE_Time_Value_T(const ACE_Time_Value& tv, + const TIME_POLICY& tp = TIME_POLICY ()) + : ACE_Time_Value (tv), + time_policy_ (tp) + {} + + /// Destructor + virtual ~ACE_Time_Value_T () {} + + /// Add @a tv to this. + ACE_Time_Value_T<TIME_POLICY> &operator += (const ACE_Time_Value &tv); + + /// Add @a tv to this. + ACE_Time_Value_T<TIME_POLICY> &operator += (time_t tv); + + /// Assign @ tv to this + ACE_Time_Value_T<TIME_POLICY> &operator = (const ACE_Time_Value_T<TIME_POLICY> &tv); + + /// Assign @ tv to this + ACE_Time_Value_T<TIME_POLICY> &operator = (const ACE_Time_Value &tv); + + /// Assign @ tv to this + ACE_Time_Value_T<TIME_POLICY> &operator = (time_t tv); + + /// Subtract @a tv to this. + ACE_Time_Value_T<TIME_POLICY> &operator -= (const ACE_Time_Value &tv); + + /// Subtract @a tv to this. + ACE_Time_Value_T<TIME_POLICY> &operator -= (time_t tv); + + /** + \brief Multiply the time value by the @a d factor. + \note The result of the operator is valid for results from range + < (ACE_INT32_MIN, -999999), (ACE_INT32_MAX, 999999) >. Result + outside this range are saturated to a limit. + */ + ACE_Time_Value_T<TIME_POLICY> &operator *= (double d); + + /// Increment microseconds as postfix. + /** + * @note The only reason this is here is to allow the use of ACE_Atomic_Op + * with ACE_Time_Value. + */ + ACE_Time_Value_T<TIME_POLICY> operator++ (int); + + /// Increment microseconds as prefix. + /** + * @note The only reason this is here is to allow the use of ACE_Atomic_Op + * with ACE_Time_Value. + */ + ACE_Time_Value_T<TIME_POLICY> &operator++ (void); + + /// Decrement microseconds as postfix. + /** + * @note The only reason this is here is to allow the use of ACE_Atomic_Op + * with ACE_Time_Value. + */ + ACE_Time_Value_T<TIME_POLICY> operator-- (int); + + /// Decrement microseconds as prefix. + /** + * @note The only reason this is here is to allow the use of ACE_Atomic_Op + * with ACE_Time_Value. + */ + ACE_Time_Value_T<TIME_POLICY> &operator-- (void); + + /// Get current time of day according to time policy. + /** + * @return Time value representing current time of day according to time policy. + */ + virtual ACE_Time_Value now () const; + + /// Converts absolute time value to time value relative to current time of day. + /** + * @return Relative time value. + * + * @note This method uses it's time_policy_ member to get the current + * time of day. + * The developer is responsible for making sure this is an absolute + * time value compatible with the active time policy. + * Note that the returned time value has no notion of the time policy + * on which it is based anymore. + */ + virtual ACE_Time_Value to_relative_time () const; + + /// Converts relative time value to absolute time value based on current time of day. + /** + * @return Absolute time value. + * + * @note This method uses it's time_policy_ member to get the current + * time of day. + * The developer is responsible for making sure this is a relative + * time value. + * Note that the returned time value has no notion of the time policy + * on which it is based anymore. + */ + virtual ACE_Time_Value to_absolute_time () const; + + /// Duplicates this time value (incl. time policy). + /** + * @return Dynamically allocated time value copy. + * + * @note The caller is responsible for freeing the copy when it's not needed + * anymore. + */ + virtual ACE_Time_Value * duplicate () const; + +private: + TIME_POLICY time_policy_; +}; + +ACE_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "ace/Time_Value_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Time_Value_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Time_Value_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" +#endif /* ACE_TIME_VALUE_T_H */ diff --git a/ACE/ace/Time_Value_T.inl b/ACE/ace/Time_Value_T.inl new file mode 100644 index 00000000000..b5470c13494 --- /dev/null +++ b/ACE/ace/Time_Value_T.inl @@ -0,0 +1,94 @@ +// -*- C++ -*- +// +// $Id$ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL + +template <class TIME_POLICY> +ACE_Time_Value_T<TIME_POLICY> &ACE_Time_Value_T<TIME_POLICY>::operator += (const ACE_Time_Value &tv) +{ + this->ACE_Time_Value::operator +=(tv); + return *this; +} + +template <class TIME_POLICY> +ACE_Time_Value_T<TIME_POLICY> &ACE_Time_Value_T<TIME_POLICY>::operator += (time_t tv) +{ + this->ACE_Time_Value::operator +=(tv); + return *this; +} + +template <class TIME_POLICY> +ACE_Time_Value_T<TIME_POLICY> &ACE_Time_Value_T<TIME_POLICY>::operator = (const ACE_Time_Value_T<TIME_POLICY> &tv) +{ + this->time_policy_ = tv.time_policy_; + this->ACE_Time_Value::operator =(tv); + return *this; +} + +template <class TIME_POLICY> +ACE_Time_Value_T<TIME_POLICY> &ACE_Time_Value_T<TIME_POLICY>::operator = (const ACE_Time_Value &tv) +{ + this->ACE_Time_Value::operator =(tv); + return *this; +} + +template <class TIME_POLICY> +ACE_Time_Value_T<TIME_POLICY> &ACE_Time_Value_T<TIME_POLICY>::operator = (time_t tv) +{ + this->ACE_Time_Value::operator =(tv); + return *this; +} + +template <class TIME_POLICY> +ACE_Time_Value_T<TIME_POLICY> &ACE_Time_Value_T<TIME_POLICY>::operator -= (const ACE_Time_Value &tv) +{ + this->ACE_Time_Value::operator -=(tv); + return *this; +} + +template <class TIME_POLICY> +ACE_Time_Value_T<TIME_POLICY> &ACE_Time_Value_T<TIME_POLICY>::operator -= (time_t tv) +{ + this->ACE_Time_Value::operator -=(tv); + return *this; +} + +template <class TIME_POLICY> +ACE_Time_Value_T<TIME_POLICY> &ACE_Time_Value_T<TIME_POLICY>::operator *= (double d) +{ + this->ACE_Time_Value::operator *=(d); + return *this; +} + +template <class TIME_POLICY> +ACE_Time_Value_T<TIME_POLICY> ACE_Time_Value_T<TIME_POLICY>::operator++ (int) +{ + ACE_Time_Value_T<TIME_POLICY> tv (*this); + ++*this; + return tv; +} + +template <class TIME_POLICY> +ACE_Time_Value_T<TIME_POLICY> &ACE_Time_Value_T<TIME_POLICY>::operator++ (void) +{ + this->ACE_Time_Value::operator ++(); + return *this; +} + +template <class TIME_POLICY> +ACE_Time_Value_T<TIME_POLICY> ACE_Time_Value_T<TIME_POLICY>::operator-- (int) +{ + ACE_Time_Value_T<TIME_POLICY> tv (*this); + --*this; + return tv; +} + +template <class TIME_POLICY> +ACE_Time_Value_T<TIME_POLICY> &ACE_Time_Value_T<TIME_POLICY>::operator-- (void) +{ + this->ACE_Time_Value::operator --(); + return *this; +} + +ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/ace.mpc b/ACE/ace/ace.mpc index 25c9296c854..e0a1e7e8bac 100644 --- a/ACE/ace/ace.mpc +++ b/ACE/ace/ace.mpc @@ -131,6 +131,7 @@ project(ACE) : ace_output, acedefaults, install, other, codecs, token, svcconf, Monitor_Size.cpp Monitor_Control_Types.cpp Monitor_Control_Action.cpp + Monotonic_Time_Policy.cpp Multihomed_INET_Addr.cpp Mutex.cpp Netlink_Addr.cpp @@ -414,6 +415,7 @@ project(ACE) : ace_output, acedefaults, install, other, codecs, token, svcconf, Metrics_Cache_T.h Memory_Pool.h Min_Max.h + Monotonic_Time_Policy.h Netlink_Addr.h Null_Barrier.h Null_Condition.h @@ -444,6 +446,7 @@ project(ACE) : ace_output, acedefaults, install, other, codecs, token, svcconf, Synch.h Synch_Traits.h TSS_T.h + Time_Policy.h Timer_Hash.h Timer_Heap.h Timer_List.h diff --git a/ACE/ace/ace_for_tao.mpc b/ACE/ace/ace_for_tao.mpc index 920c6fa6dd7..f222f8da585 100644 --- a/ACE/ace/ace_for_tao.mpc +++ b/ACE/ace/ace_for_tao.mpc @@ -94,6 +94,7 @@ project(ACE_FOR_TAO) : acedefaults, install, svcconf, uuid, versioned_namespace, Monitor_Size.cpp Monitor_Control_Types.cpp Monitor_Control_Action.cpp + Monotonic_Time_Policy.cpp Mutex.cpp Notification_Strategy.cpp Notification_Queue.cpp @@ -322,6 +323,7 @@ project(ACE_FOR_TAO) : acedefaults, install, svcconf, uuid, versioned_namespace, Memory_Pool.h Mem_Map.h Min_Max.h + Monotonic_Time_Policy.h Null_Barrier.h Null_Condition.h Null_Mutex.h @@ -346,6 +348,7 @@ project(ACE_FOR_TAO) : acedefaults, install, svcconf, uuid, versioned_namespace, Synch.h Synch_Traits.h TSS_T.h + Time_Policy.h Timer_Queuefwd.h Truncate.h Value_Ptr.h |