From f25c7a2aa1e464b424ba5add600f9a3e0edc9ee2 Mon Sep 17 00:00:00 2001 From: mcorino Date: Thu, 16 Aug 2012 09:36:07 +0000 Subject: ChangeLogTag: Thu Aug 16 09:22:31 UTC 2012 Martin Corino --- ACE/ace/Condition_Attributes.cpp | 1 + ACE/ace/Condition_Attributes.h | 41 +- ACE/ace/Condition_Attributes.inl | 14 + ACE/ace/Condition_Recursive_Thread_Mutex.cpp | 24 +- ACE/ace/Condition_Recursive_Thread_Mutex.h | 13 +- ACE/ace/Condition_T.cpp | 16 + ACE/ace/Condition_T.h | 8 +- ACE/ace/Condition_Thread_Mutex.cpp | 60 +- ACE/ace/Condition_Thread_Mutex.h | 37 +- ACE/ace/Condition_Thread_Mutex.inl | 8 +- ACE/ace/Message_Queue.h | 4 +- ACE/ace/Message_Queue_T.cpp | 814 ++++++++++++++------------- ACE/ace/Message_Queue_T.h | 91 +-- ACE/ace/Module.cpp | 82 +-- ACE/ace/Module.h | 30 +- ACE/ace/Module.inl | 48 +- ACE/ace/Monotonic_Time_Policy.cpp | 7 + ACE/ace/Monotonic_Time_Policy.h | 50 ++ ACE/ace/Monotonic_Time_Policy.inl | 33 ++ ACE/ace/Null_Condition.h | 34 +- ACE/ace/OS_NS_Thread.cpp | 22 +- ACE/ace/OS_NS_Thread.h | 4 + ACE/ace/OS_NS_Thread.inl | 63 ++- ACE/ace/Stream.cpp | 224 ++++---- ACE/ace/Stream.h | 52 +- ACE/ace/Stream.inl | 36 +- ACE/ace/Stream_Modules.cpp | 205 +++---- ACE/ace/Stream_Modules.h | 18 +- ACE/ace/Synch_Traits.h | 9 +- ACE/ace/Task_Ex_T.cpp | 40 +- ACE/ace/Task_Ex_T.h | 20 +- ACE/ace/Task_Ex_T.inl | 66 +-- ACE/ace/Task_T.cpp | 41 +- ACE/ace/Task_T.h | 38 +- ACE/ace/Task_T.inl | 84 +-- ACE/ace/Thread_Manager.cpp | 27 +- ACE/ace/Thread_Manager.h | 5 + ACE/ace/Thread_Mutex.h | 1 - ACE/ace/Time_Policy.cpp | 19 +- ACE/ace/Time_Policy.h | 65 +-- ACE/ace/Time_Policy.inl | 22 +- ACE/ace/Time_Policy_T.cpp | 6 +- ACE/ace/Time_Policy_T.h | 4 +- ACE/ace/Time_Policy_T.inl | 6 +- ACE/ace/Time_Value.cpp | 33 ++ ACE/ace/Time_Value.h | 48 ++ ACE/ace/Time_Value_T.cpp | 52 ++ ACE/ace/Time_Value_T.h | 194 +++++++ ACE/ace/Time_Value_T.inl | 94 ++++ ACE/ace/ace.mpc | 3 + ACE/ace/ace_for_tao.mpc | 3 + 51 files changed, 1835 insertions(+), 1084 deletions(-) create mode 100644 ACE/ace/Monotonic_Time_Policy.cpp create mode 100644 ACE/ace/Monotonic_Time_Policy.h create mode 100644 ACE/ace/Monotonic_Time_Policy.inl create mode 100644 ACE/ace/Time_Value_T.cpp create mode 100644 ACE/ace/Time_Value_T.h create mode 100644 ACE/ace/Time_Value_T.inl (limited to 'ACE/ace') 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 */ +#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 friend class ACE_Condition; /// The attributes ACE_condattr_t attributes_; @@ -51,6 +51,43 @@ private: ACE_Condition_Attributes (const ACE_Condition_Attributes &); }; +template +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 &); + ACE_Condition_Attributes_T (const ACE_Condition_Attributes_T &); +}; + +class ACE_Monotonic_Time_Policy; + +template <> +class ACE_Export ACE_Condition_Attributes_T + : 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_Condition_Attributes_T (const ACE_Condition_Attributes_T &); +}; + 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_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_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_Condition (void) ACE_Condition::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_Condition"))); +} + +ACE_Condition::ACE_Condition (ACE_Recursive_Thread_Mutex &m, + const ACE_Condition_Attributes &attributes) + : mutex_ (m) +{ + if (ACE_OS::cond_init (&this->cond_, + const_cast (attributes).attributes_) != 0) + ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Condition::ACE_Condition"))); } int @@ -118,12 +128,6 @@ ACE_Condition::mutex (void) return this->mutex_; } -ACE_Condition_Recursive_Thread_Mutex::ACE_Condition_Recursive_Thread_Mutex ( - ACE_Recursive_Thread_Mutex &m) : - ACE_Condition (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 -{ -public: - /// Initialize the condition variable with a recursive mutex. - ACE_Condition_Recursive_Thread_Mutex (ACE_Recursive_Thread_Mutex &m); -}; +typedef ACE_Condition 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 @@ -72,6 +72,22 @@ ACE_Condition::ACE_Condition (MUTEX &m, ACE_TEXT ("ACE_Condition::ACE_Condition"))); } +template +ACE_Condition::ACE_Condition (MUTEX &m, + const ACE_Condition_Attributes &attributes, + const ACE_TCHAR *name, + void *arg) + : mutex_ (m) +{ +// ACE_TRACE ("ACE_Condition::ACE_Condition"); + if (ACE_OS::cond_init (&this->cond_, + const_cast (attributes).attributes_, + name, arg) != 0) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("ACE_Condition::ACE_Condition"))); +} + template ACE_Condition::~ACE_Condition (void) { 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) void -ACE_Condition_Thread_Mutex::dump (void) const +ACE_Condition::dump (void) const { #if defined (ACE_HAS_DUMP) -// ACE_TRACE ("ACE_Condition_Thread_Mutex::dump"); +// ACE_TRACE ("ACE_Condition::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_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_Condition"); 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_Condition"))); } -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_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_Condition"); + if (ACE_OS::cond_init (&this->cond_, + const_cast (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_Condition"))); } -ACE_Condition_Thread_Mutex::~ACE_Condition_Thread_Mutex (void) +ACE_Condition::~ACE_Condition (void) { -// ACE_TRACE ("ACE_Condition_Thread_Mutex::~ACE_Condition_Thread_Mutex"); +// ACE_TRACE ("ACE_Condition::~ACE_Condition"); this->remove (); } @@ -82,40 +82,40 @@ ACE_Condition_Thread_Mutex::~ACE_Condition_Thread_Mutex (void) // using the function. int -ACE_Condition_Thread_Mutex::wait (void) +ACE_Condition::wait (void) { -// ACE_TRACE ("ACE_Condition_Thread_Mutex::wait"); - return ACE_OS::cond_wait (&this->cond_, &this->mutex_.lock_); +// ACE_TRACE ("ACE_Condition::wait"); + return ACE_OS::cond_wait (&this->cond_, &this->mutex_.lock ()); } int -ACE_Condition_Thread_Mutex::wait (ACE_Thread_Mutex &mutex, +ACE_Condition::wait (ACE_Thread_Mutex &mutex, const ACE_Time_Value *abstime) { -// ACE_TRACE ("ACE_Condition_Thread_Mutex::wait"); +// ACE_TRACE ("ACE_Condition::wait"); return ACE_OS::cond_timedwait (&this->cond_, - &mutex.lock_, + &mutex.lock (), const_cast (abstime)); } int -ACE_Condition_Thread_Mutex::wait (const ACE_Time_Value *abstime) +ACE_Condition::wait (const ACE_Time_Value *abstime) { -// ACE_TRACE ("ACE_Condition_Thread_Mutex::wait"); +// ACE_TRACE ("ACE_Condition::wait"); return this->wait (this->mutex_, abstime); } int -ACE_Condition_Thread_Mutex::signal (void) +ACE_Condition::signal (void) { -// ACE_TRACE ("ACE_Condition_Thread_Mutex::signal"); +// ACE_TRACE ("ACE_Condition::signal"); return ACE_OS::cond_signal (&this->cond_); } int -ACE_Condition_Thread_Mutex::broadcast (void) +ACE_Condition::broadcast (void) { -// ACE_TRACE ("ACE_Condition_Thread_Mutex::broadcast"); +// ACE_TRACE ("ACE_Condition::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_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 { 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_Condition (const ACE_Condition &); }; +typedef ACE_Condition 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::remove (void) { -// ACE_TRACE ("ACE_Condition_Thread_Mutex::remove"); +// ACE_TRACE ("ACE_Condition::remove"); // 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::mutex (void) { -// ACE_TRACE ("ACE_Condition_Thread_Mutex::mutex"); +// ACE_TRACE ("ACE_Condition::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 class ACE_Message_Queue_Iterator; -template class ACE_Message_Queue_Reverse_Iterator; +template class ACE_Message_Queue_Iterator; +template 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 void -ACE_Message_Queue_Ex::dump (void) const +template void +ACE_Message_Queue_Ex::dump (void) const { #if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Message_Queue_Ex::dump"); + ACE_TRACE ("ACE_Message_Queue_Ex::dump"); this->queue_.dump (); #endif /* ACE_HAS_DUMP */ } -template void -ACE_Message_Queue_Ex::message_bytes (size_t new_value) +template void +ACE_Message_Queue_Ex::message_bytes (size_t new_value) { - ACE_TRACE ("ACE_Message_Queue_Ex::message_bytes"); + ACE_TRACE ("ACE_Message_Queue_Ex::message_bytes"); this->queue_.message_bytes (new_value); } -template void -ACE_Message_Queue_Ex::message_length (size_t new_value) +template void +ACE_Message_Queue_Ex::message_length (size_t new_value) { - ACE_TRACE ("ACE_Message_Queue_Ex::message_length"); + ACE_TRACE ("ACE_Message_Queue_Ex::message_length"); this->queue_.message_length (new_value); } -template -ACE_Message_Queue_Ex::ACE_Message_Queue_Ex (size_t high_water_mark, +template +ACE_Message_Queue_Ex::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_Queue_Ex"); + ACE_TRACE ("ACE_Message_Queue_Ex::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 -ACE_Message_Queue_Ex::~ACE_Message_Queue_Ex (void) +template +ACE_Message_Queue_Ex::~ACE_Message_Queue_Ex (void) { - ACE_TRACE ("ACE_Message_Queue_Ex::~ACE_Message_Queue_Ex"); + ACE_TRACE ("ACE_Message_Queue_Ex::~ACE_Message_Queue_Ex"); } -template int -ACE_Message_Queue_Ex::open (size_t hwm, +template int +ACE_Message_Queue_Ex::open (size_t hwm, size_t lwm, ACE_Notification_Strategy *ns) { - ACE_TRACE ("ACE_Message_Queue_Ex::open"); + ACE_TRACE ("ACE_Message_Queue_Ex::open"); return this->queue_.open (hwm, lwm, ns); } // Clean up the queue if we have not already done so! -template int -ACE_Message_Queue_Ex::close (void) +template int +ACE_Message_Queue_Ex::close (void) { - ACE_TRACE ("ACE_Message_Queue_Ex::close"); + ACE_TRACE ("ACE_Message_Queue_Ex::close"); return this->queue_.close (); } -template int -ACE_Message_Queue_Ex::flush (void) +template int +ACE_Message_Queue_Ex::flush (void) { - ACE_TRACE ("ACE_Message_Queue_Ex::flush"); + ACE_TRACE ("ACE_Message_Queue_Ex::flush"); return this->queue_.flush (); } -template int -ACE_Message_Queue_Ex::flush_i (void) +template int +ACE_Message_Queue_Ex::flush_i (void) { - ACE_TRACE ("ACE_Message_Queue_Ex::flush_i"); + ACE_TRACE ("ACE_Message_Queue_Ex::flush_i"); return this->queue_.flush_i (); } // Take a look at the first item without removing it. -template int -ACE_Message_Queue_Ex::peek_dequeue_head (ACE_MESSAGE_TYPE *&first_item, +template int +ACE_Message_Queue_Ex::peek_dequeue_head (ACE_MESSAGE_TYPE *&first_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue_Ex::peek_dequeue_head"); + ACE_TRACE ("ACE_Message_Queue_Ex::peek_dequeue_head"); ACE_Message_Block *mb = 0; @@ -132,18 +133,18 @@ ACE_Message_Queue_Ex::peek_dequeue_head (ACE_ME return cur_count; } -template int -ACE_Message_Queue_Ex::enqueue_head (ACE_MESSAGE_TYPE *new_item, +template int +ACE_Message_Queue_Ex::enqueue_head (ACE_MESSAGE_TYPE *new_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue_Ex::enqueue_head"); + ACE_TRACE ("ACE_Message_Queue_Ex::enqueue_head"); ACE_Message_Block *mb = 0; ACE_NEW_RETURN (mb, ACE_Message_Block ((char *) new_item, sizeof (*new_item), - ACE_Message_Queue_Ex::DEFAULT_PRIORITY), + ACE_Message_Queue_Ex::DEFAULT_PRIORITY), -1); int const result = this->queue_.enqueue_head (mb, timeout); @@ -157,21 +158,21 @@ ACE_Message_Queue_Ex::enqueue_head (ACE_MESSAGE // accordance with its (0 is lowest priority). Returns // -1 on failure, else the number of items still on the queue. -template int -ACE_Message_Queue_Ex::enqueue (ACE_MESSAGE_TYPE *new_item, +template int +ACE_Message_Queue_Ex::enqueue (ACE_MESSAGE_TYPE *new_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue_Ex::enqueue"); + ACE_TRACE ("ACE_Message_Queue_Ex::enqueue"); return this->enqueue_prio (new_item, timeout); } -template int -ACE_Message_Queue_Ex::enqueue_prio (ACE_MESSAGE_TYPE *new_item, +template int +ACE_Message_Queue_Ex::enqueue_prio (ACE_MESSAGE_TYPE *new_item, ACE_Time_Value *timeout, unsigned long priority) { - ACE_TRACE ("ACE_Message_Queue_Ex::enqueue_prio"); + ACE_TRACE ("ACE_Message_Queue_Ex::enqueue_prio"); ACE_Message_Block *mb = 0; @@ -189,18 +190,18 @@ ACE_Message_Queue_Ex::enqueue_prio (ACE_MESSAGE return result; } -template int -ACE_Message_Queue_Ex::enqueue_deadline (ACE_MESSAGE_TYPE *new_item, +template int +ACE_Message_Queue_Ex::enqueue_deadline (ACE_MESSAGE_TYPE *new_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue_Ex::enqueue_deadline"); + ACE_TRACE ("ACE_Message_Queue_Ex::enqueue_deadline"); ACE_Message_Block *mb = 0; ACE_NEW_RETURN (mb, ACE_Message_Block ((char *) new_item, sizeof (*new_item), - ACE_Message_Queue_Ex::DEFAULT_PRIORITY ), + ACE_Message_Queue_Ex::DEFAULT_PRIORITY ), -1); int const result = this->queue_.enqueue_deadline (mb, timeout); @@ -214,18 +215,18 @@ ACE_Message_Queue_Ex::enqueue_deadline (ACE_MES // Block indefinitely waiting for an item to arrive, // does not ignore alerts (e.g., signals). -template int -ACE_Message_Queue_Ex::enqueue_tail (ACE_MESSAGE_TYPE *new_item, +template int +ACE_Message_Queue_Ex::enqueue_tail (ACE_MESSAGE_TYPE *new_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue_Ex::enqueue_tail"); + ACE_TRACE ("ACE_Message_Queue_Ex::enqueue_tail"); ACE_Message_Block *mb = 0; ACE_NEW_RETURN (mb, ACE_Message_Block ((char *) new_item, sizeof (*new_item), - ACE_Message_Queue_Ex::DEFAULT_PRIORITY), + ACE_Message_Queue_Ex::DEFAULT_PRIORITY), -1); int const result = this->queue_.enqueue_tail (mb, timeout); @@ -239,11 +240,11 @@ ACE_Message_Queue_Ex::enqueue_tail (ACE_MESSAGE // indefinitely (or until an alert occurs). Otherwise, block for upto // the amount of time specified by timeout. -template int -ACE_Message_Queue_Ex::dequeue_head (ACE_MESSAGE_TYPE *&first_item, +template int +ACE_Message_Queue_Ex::dequeue_head (ACE_MESSAGE_TYPE *&first_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue_Ex::dequeue_head"); + ACE_TRACE ("ACE_Message_Queue_Ex::dequeue_head"); ACE_Message_Block *mb = 0; @@ -264,11 +265,11 @@ ACE_Message_Queue_Ex::dequeue_head (ACE_MESSAGE // block indefinitely (or until an alert occurs). Otherwise, block for upto // the amount of time specified by timeout. -template int -ACE_Message_Queue_Ex::dequeue_prio (ACE_MESSAGE_TYPE *&dequeued, +template int +ACE_Message_Queue_Ex::dequeue_prio (ACE_MESSAGE_TYPE *&dequeued, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue_Ex::dequeue_prio"); + ACE_TRACE ("ACE_Message_Queue_Ex::dequeue_prio"); ACE_Message_Block *mb = 0; @@ -289,11 +290,11 @@ ACE_Message_Queue_Ex::dequeue_prio (ACE_MESSAGE // indefinitely (or until an alert occurs). Otherwise, block for upto // the amount of time specified by timeout. -template int -ACE_Message_Queue_Ex::dequeue_tail (ACE_MESSAGE_TYPE *&dequeued, +template int +ACE_Message_Queue_Ex::dequeue_tail (ACE_MESSAGE_TYPE *&dequeued, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue_Ex::dequeue_tail"); + ACE_TRACE ("ACE_Message_Queue_Ex::dequeue_tail"); ACE_Message_Block *mb = 0; @@ -314,11 +315,11 @@ ACE_Message_Queue_Ex::dequeue_tail (ACE_MESSAGE // indefinitely (or until an alert occurs). Otherwise, block for upto // the amount of time specified by timeout. -template int -ACE_Message_Queue_Ex::dequeue_deadline (ACE_MESSAGE_TYPE *&dequeued, +template int +ACE_Message_Queue_Ex::dequeue_deadline (ACE_MESSAGE_TYPE *&dequeued, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue_Ex::dequeue_deadline"); + ACE_TRACE ("ACE_Message_Queue_Ex::dequeue_deadline"); ACE_Message_Block *mb = 0; @@ -335,24 +336,24 @@ ACE_Message_Queue_Ex::dequeue_deadline (ACE_MES return cur_count; } -template int -ACE_Message_Queue_Ex::notify (void) +template int +ACE_Message_Queue_Ex::notify (void) { - ACE_TRACE ("ACE_Message_Queue_Ex::notify"); + ACE_TRACE ("ACE_Message_Queue_Ex::notify"); return this->queue_.notify (); } -template -ACE_Message_Queue_Ex_Iterator:: -ACE_Message_Queue_Ex_Iterator (ACE_Message_Queue_Ex & queue) +template +ACE_Message_Queue_Ex_Iterator:: +ACE_Message_Queue_Ex_Iterator (ACE_Message_Queue_Ex & queue) : iter_ (queue.queue_) { } -template int -ACE_Message_Queue_Ex_Iterator:: +template int +ACE_Message_Queue_Ex_Iterator:: next (ACE_MESSAGE_TYPE *&entry) { ACE_Message_Block * mb = 0; @@ -364,36 +365,36 @@ next (ACE_MESSAGE_TYPE *&entry) return retval; } -template int -ACE_Message_Queue_Ex_Iterator::done (void) const +template int +ACE_Message_Queue_Ex_Iterator::done (void) const { return this->iter_.done (); } -template int -ACE_Message_Queue_Ex_Iterator::advance (void) +template int +ACE_Message_Queue_Ex_Iterator::advance (void) { return this->iter_.advance (); } -template void -ACE_Message_Queue_Ex_Iterator::dump (void) const +template void +ACE_Message_Queue_Ex_Iterator::dump (void) const { this->iter_.dump (); } ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Ex_Iterator) -template -ACE_Message_Queue_Ex_Reverse_Iterator:: -ACE_Message_Queue_Ex_Reverse_Iterator (ACE_Message_Queue_Ex & queue) +template +ACE_Message_Queue_Ex_Reverse_Iterator:: +ACE_Message_Queue_Ex_Reverse_Iterator (ACE_Message_Queue_Ex & queue) : iter_ (queue.queue_) { } -template int -ACE_Message_Queue_Ex_Reverse_Iterator:: +template int +ACE_Message_Queue_Ex_Reverse_Iterator:: next (ACE_MESSAGE_TYPE *&entry) { ACE_Message_Block * mb = 0; @@ -405,50 +406,50 @@ next (ACE_MESSAGE_TYPE *&entry) return retval; } -template int -ACE_Message_Queue_Ex_Reverse_Iterator::done (void) const +template int +ACE_Message_Queue_Ex_Reverse_Iterator::done (void) const { return this->iter_.done (); } -template int -ACE_Message_Queue_Ex_Reverse_Iterator::advance (void) +template int +ACE_Message_Queue_Ex_Reverse_Iterator::advance (void) { return this->iter_.advance (); } -template void -ACE_Message_Queue_Ex_Reverse_Iterator::dump (void) const +template void +ACE_Message_Queue_Ex_Reverse_Iterator::dump (void) const { this->iter_.dump (); } ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Ex_Reverse_Iterator) -template -ACE_Message_Queue_Ex_N::ACE_Message_Queue_Ex_N +template +ACE_Message_Queue_Ex_N::ACE_Message_Queue_Ex_N (size_t high_water_mark, size_t low_water_mark, ACE_Notification_Strategy *ns): - ACE_Message_Queue_Ex (high_water_mark, + ACE_Message_Queue_Ex (high_water_mark, low_water_mark, ns) { - ACE_TRACE ("ACE_Message_Queue_Ex_N::ACE_Message_Queue_Ex_N"); + ACE_TRACE ("ACE_Message_Queue_Ex_N::ACE_Message_Queue_Ex_N"); } -template -ACE_Message_Queue_Ex_N::~ACE_Message_Queue_Ex_N (void) +template +ACE_Message_Queue_Ex_N::~ACE_Message_Queue_Ex_N (void) { - ACE_TRACE ("ACE_Message_Queue_Ex_N::~ACE_Message_Queue_Ex_N"); + ACE_TRACE ("ACE_Message_Queue_Ex_N::~ACE_Message_Queue_Ex_N"); } -template int -ACE_Message_Queue_Ex_N::enqueue_head +template int +ACE_Message_Queue_Ex_N::enqueue_head (ACE_MESSAGE_TYPE *new_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue_Ex_N::enqueue_head"); + ACE_TRACE ("ACE_Message_Queue_Ex_N::enqueue_head"); // Create a chained ACE_Message_Blocks wrappers around the 'chained' // ACE_MESSAGE_TYPES. @@ -467,12 +468,12 @@ ACE_Message_Queue_Ex_N::enqueue_head return result; } -template int -ACE_Message_Queue_Ex_N::enqueue_tail +template int +ACE_Message_Queue_Ex_N::enqueue_tail (ACE_MESSAGE_TYPE *new_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue_Ex_N::enqueue_tail"); + ACE_TRACE ("ACE_Message_Queue_Ex_N::enqueue_tail"); // Create a chained ACE_Message_Blocks wrappers around the 'chained' // ACE_MESSAGE_TYPES. @@ -491,11 +492,11 @@ ACE_Message_Queue_Ex_N::enqueue_tail return result; } -template ACE_Message_Block * -ACE_Message_Queue_Ex_N::wrap_with_mbs_i +template ACE_Message_Block * +ACE_Message_Queue_Ex_N::wrap_with_mbs_i (ACE_MESSAGE_TYPE *new_item) { - ACE_TRACE ("ACE_Message_Queue_Ex_N::wrap_with_mbs_i"); + ACE_TRACE ("ACE_Message_Queue_Ex_N::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::wrap_with_mbs_i ACE_NEW_RETURN (mb_head, ACE_Message_Block ((char *) new_item, sizeof (*new_item), - ACE_Message_Queue_Ex::DEFAULT_PRIORITY), + ACE_Message_Queue_Ex::DEFAULT_PRIORITY), 0); // mb_tail will point to the last ACE_Message_Block @@ -516,7 +517,7 @@ ACE_Message_Queue_Ex_N::wrap_with_mbs_i ACE_NEW_NORETURN (mb_temp, ACE_Message_Block ((char *) pobj, sizeof (*pobj), - ACE_Message_Queue_Ex::DEFAULT_PRIORITY)); + ACE_Message_Queue_Ex::DEFAULT_PRIORITY)); if (mb_temp == 0) { mb_head->release (); @@ -533,162 +534,176 @@ ACE_Message_Queue_Ex_N::wrap_with_mbs_i ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Reverse_Iterator) -template int -ACE_Message_Queue_Ex::dequeue (ACE_MESSAGE_TYPE *&first_item, +template int +ACE_Message_Queue_Ex::dequeue (ACE_MESSAGE_TYPE *&first_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue_Ex::dequeue"); + ACE_TRACE ("ACE_Message_Queue_Ex::dequeue"); return this->dequeue_head (first_item, timeout); } -template ACE_Notification_Strategy * -ACE_Message_Queue_Ex::notification_strategy (void) +template ACE_Notification_Strategy * +ACE_Message_Queue_Ex::notification_strategy (void) { - ACE_TRACE ("ACE_Message_Queue_Ex::notification_strategy"); + ACE_TRACE ("ACE_Message_Queue_Ex::notification_strategy"); return this->queue_.notification_strategy (); } -template void -ACE_Message_Queue_Ex::notification_strategy (ACE_Notification_Strategy *s) +template void +ACE_Message_Queue_Ex::notification_strategy (ACE_Notification_Strategy *s) { - ACE_TRACE ("ACE_Message_Queue_Ex::notification_strategy"); + ACE_TRACE ("ACE_Message_Queue_Ex::notification_strategy"); this->queue_.notification_strategy (s); } // Check if queue is empty (holds locks). -template bool -ACE_Message_Queue_Ex::is_empty (void) +template bool +ACE_Message_Queue_Ex::is_empty (void) { - ACE_TRACE ("ACE_Message_Queue_Ex::is_empty"); + ACE_TRACE ("ACE_Message_Queue_Ex::is_empty"); return this->queue_.is_empty (); } // Check if queue is full (holds locks). -template bool -ACE_Message_Queue_Ex::is_full (void) +template bool +ACE_Message_Queue_Ex::is_full (void) { - ACE_TRACE ("ACE_Message_Queue_Ex::is_full"); + ACE_TRACE ("ACE_Message_Queue_Ex::is_full"); return this->queue_.is_full (); } -template size_t -ACE_Message_Queue_Ex::high_water_mark (void) +template size_t +ACE_Message_Queue_Ex::high_water_mark (void) { - ACE_TRACE ("ACE_Message_Queue_Ex::high_water_mark"); + ACE_TRACE ("ACE_Message_Queue_Ex::high_water_mark"); return this->queue_.high_water_mark (); } -template void -ACE_Message_Queue_Ex::high_water_mark (size_t hwm) +template void +ACE_Message_Queue_Ex::high_water_mark (size_t hwm) { - ACE_TRACE ("ACE_Message_Queue_Ex::high_water_mark"); + ACE_TRACE ("ACE_Message_Queue_Ex::high_water_mark"); this->queue_.high_water_mark (hwm); } -template size_t -ACE_Message_Queue_Ex::low_water_mark (void) +template size_t +ACE_Message_Queue_Ex::low_water_mark (void) { - ACE_TRACE ("ACE_Message_Queue_Ex::low_water_mark"); + ACE_TRACE ("ACE_Message_Queue_Ex::low_water_mark"); return this->queue_.low_water_mark (); } -template void -ACE_Message_Queue_Ex::low_water_mark (size_t lwm) +template void +ACE_Message_Queue_Ex::low_water_mark (size_t lwm) { - ACE_TRACE ("ACE_Message_Queue_Ex::low_water_mark"); + ACE_TRACE ("ACE_Message_Queue_Ex::low_water_mark"); this->queue_.low_water_mark (lwm); } -template size_t -ACE_Message_Queue_Ex::message_bytes (void) +template size_t +ACE_Message_Queue_Ex::message_bytes (void) { - ACE_TRACE ("ACE_Message_Queue_Ex::message_bytes"); + ACE_TRACE ("ACE_Message_Queue_Ex::message_bytes"); return this->queue_.message_bytes (); } -template size_t -ACE_Message_Queue_Ex::message_length (void) +template size_t +ACE_Message_Queue_Ex::message_length (void) { - ACE_TRACE ("ACE_Message_Queue_Ex::message_length"); + ACE_TRACE ("ACE_Message_Queue_Ex::message_length"); return this->queue_.message_length (); } -template size_t -ACE_Message_Queue_Ex::message_count (void) +template size_t +ACE_Message_Queue_Ex::message_count (void) { - ACE_TRACE ("ACE_Message_Queue_Ex::message_count"); + ACE_TRACE ("ACE_Message_Queue_Ex::message_count"); return this->queue_.message_count (); } -template int -ACE_Message_Queue_Ex::deactivate (void) +template int +ACE_Message_Queue_Ex::deactivate (void) { - ACE_TRACE ("ACE_Message_Queue_Ex::deactivate"); + ACE_TRACE ("ACE_Message_Queue_Ex::deactivate"); return this->queue_.deactivate (); } -template int -ACE_Message_Queue_Ex::activate (void) +template int +ACE_Message_Queue_Ex::activate (void) { - ACE_TRACE ("ACE_Message_Queue_Ex::activate"); + ACE_TRACE ("ACE_Message_Queue_Ex::activate"); return this->queue_.activate (); } -template int -ACE_Message_Queue_Ex::pulse (void) +template int +ACE_Message_Queue_Ex::pulse (void) { - ACE_TRACE ("ACE_Message_Queue_Ex::pulse"); + ACE_TRACE ("ACE_Message_Queue_Ex::pulse"); return this->queue_.pulse (); } -template int -ACE_Message_Queue_Ex::deactivated (void) +template int +ACE_Message_Queue_Ex::deactivated (void) { - ACE_TRACE ("ACE_Message_Queue_Ex::deactivated"); + ACE_TRACE ("ACE_Message_Queue_Ex::deactivated"); return this->queue_.deactivated (); } -template int -ACE_Message_Queue_Ex::state (void) +template int +ACE_Message_Queue_Ex::state (void) { - ACE_TRACE ("ACE_Message_Queue_Ex::state"); + ACE_TRACE ("ACE_Message_Queue_Ex::state"); return this->queue_.state (); } -template ACE_SYNCH_MUTEX_T & -ACE_Message_Queue_Ex::lock (void) +template ACE_SYNCH_MUTEX_T & +ACE_Message_Queue_Ex::lock (void) { return this->queue_.lock (); } -template -ACE_Message_Queue_Iterator::ACE_Message_Queue_Iterator (ACE_Message_Queue &q) +template +ACE_Time_Value_T +ACE_Message_Queue_Ex::gettimeofday () +{ + return this->queue_.gettimeofday (); +} + +template +void +ACE_Message_Queue_Ex::set_time_policy (TIME_POLICY const & rhs) +{ + this->queue_.set_time_policy (rhs); +} + +template +ACE_Message_Queue_Iterator::ACE_Message_Queue_Iterator (ACE_Message_Queue &q) : queue_ (q), curr_ (q.head_) { } -template int -ACE_Message_Queue_Iterator::next (ACE_Message_Block *&entry) +template int +ACE_Message_Queue_Iterator::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::next (ACE_Message_Block *&entry) return 0; } -template int -ACE_Message_Queue_Iterator::done (void) const +template int +ACE_Message_Queue_Iterator::done (void) const { ACE_READ_GUARD_RETURN (ACE_SYNCH_MUTEX_T, m, this->queue_.lock_, -1) return this->curr_ == 0; } -template int -ACE_Message_Queue_Iterator::advance (void) +template int +ACE_Message_Queue_Iterator::advance (void) { ACE_READ_GUARD_RETURN (ACE_SYNCH_MUTEX_T, m, this->queue_.lock_, -1) @@ -719,8 +734,8 @@ ACE_Message_Queue_Iterator::advance (void) return this->curr_ != 0; } -template void -ACE_Message_Queue_Iterator::dump (void) const +template void +ACE_Message_Queue_Iterator::dump (void) const { #if defined (ACE_HAS_DUMP) #endif /* ACE_HAS_DUMP */ @@ -728,15 +743,15 @@ ACE_Message_Queue_Iterator::dump (void) const ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Iterator) -template -ACE_Message_Queue_Reverse_Iterator::ACE_Message_Queue_Reverse_Iterator (ACE_Message_Queue &q) +template +ACE_Message_Queue_Reverse_Iterator::ACE_Message_Queue_Reverse_Iterator (ACE_Message_Queue &q) : queue_ (q), curr_ (queue_.tail_) { } -template int -ACE_Message_Queue_Reverse_Iterator::next (ACE_Message_Block *&entry) +template int +ACE_Message_Queue_Reverse_Iterator::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::next (ACE_Message_Block *&ent return 0; } -template int -ACE_Message_Queue_Reverse_Iterator::done (void) const +template int +ACE_Message_Queue_Reverse_Iterator::done (void) const { ACE_READ_GUARD_RETURN (ACE_SYNCH_MUTEX_T, m, this->queue_.lock_, -1) return this->curr_ == 0; } -template int -ACE_Message_Queue_Reverse_Iterator::advance (void) +template int +ACE_Message_Queue_Reverse_Iterator::advance (void) { ACE_READ_GUARD_RETURN (ACE_SYNCH_MUTEX_T, m, this->queue_.lock_, -1) @@ -767,61 +782,61 @@ ACE_Message_Queue_Reverse_Iterator::advance (void) return this->curr_ != 0; } -template void -ACE_Message_Queue_Reverse_Iterator::dump (void) const +template void +ACE_Message_Queue_Reverse_Iterator::dump (void) const { #if defined (ACE_HAS_DUMP) #endif /* ACE_HAS_DUMP */ } -template int -ACE_Message_Queue::dequeue (ACE_Message_Block *&first_item, +template int +ACE_Message_Queue::dequeue (ACE_Message_Block *&first_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue::dequeue"); + ACE_TRACE ("ACE_Message_Queue::dequeue"); return this->dequeue_head (first_item, timeout); } -template ACE_Notification_Strategy * -ACE_Message_Queue::notification_strategy (void) +template ACE_Notification_Strategy * +ACE_Message_Queue::notification_strategy (void) { - ACE_TRACE ("ACE_Message_Queue::notification_strategy"); + ACE_TRACE ("ACE_Message_Queue::notification_strategy"); return this->notification_strategy_; } -template void -ACE_Message_Queue::notification_strategy (ACE_Notification_Strategy *s) +template void +ACE_Message_Queue::notification_strategy (ACE_Notification_Strategy *s) { - ACE_TRACE ("ACE_Message_Queue::notification_strategy"); + ACE_TRACE ("ACE_Message_Queue::notification_strategy"); this->notification_strategy_ = s; } // Check if queue is empty (does not hold locks). -template bool -ACE_Message_Queue::is_empty_i (void) +template bool +ACE_Message_Queue::is_empty_i (void) { - ACE_TRACE ("ACE_Message_Queue::is_empty_i"); + ACE_TRACE ("ACE_Message_Queue::is_empty_i"); return this->tail_ == 0; } // Check if queue is full (does not hold locks). -template bool -ACE_Message_Queue::is_full_i (void) +template bool +ACE_Message_Queue::is_full_i (void) { - ACE_TRACE ("ACE_Message_Queue::is_full_i"); + ACE_TRACE ("ACE_Message_Queue::is_full_i"); return this->cur_bytes_ >= this->high_water_mark_; } // Check if queue is empty (holds locks). -template bool -ACE_Message_Queue::is_empty (void) +template bool +ACE_Message_Queue::is_empty (void) { - ACE_TRACE ("ACE_Message_Queue::is_empty"); + ACE_TRACE ("ACE_Message_Queue::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::is_empty (void) // Check if queue is full (holds locks). -template bool -ACE_Message_Queue::is_full (void) +template bool +ACE_Message_Queue::is_full (void) { - ACE_TRACE ("ACE_Message_Queue::is_full"); + ACE_TRACE ("ACE_Message_Queue::is_full"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, false); return this->is_full_i (); } -template size_t -ACE_Message_Queue::high_water_mark (void) +template size_t +ACE_Message_Queue::high_water_mark (void) { - ACE_TRACE ("ACE_Message_Queue::high_water_mark"); + ACE_TRACE ("ACE_Message_Queue::high_water_mark"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, 0); return this->high_water_mark_; } -template void -ACE_Message_Queue::high_water_mark (size_t hwm) +template void +ACE_Message_Queue::high_water_mark (size_t hwm) { - ACE_TRACE ("ACE_Message_Queue::high_water_mark"); + ACE_TRACE ("ACE_Message_Queue::high_water_mark"); ACE_GUARD (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_); this->high_water_mark_ = hwm; } -template size_t -ACE_Message_Queue::low_water_mark (void) +template size_t +ACE_Message_Queue::low_water_mark (void) { - ACE_TRACE ("ACE_Message_Queue::low_water_mark"); + ACE_TRACE ("ACE_Message_Queue::low_water_mark"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, 0); return this->low_water_mark_; } -template void -ACE_Message_Queue::low_water_mark (size_t lwm) +template void +ACE_Message_Queue::low_water_mark (size_t lwm) { - ACE_TRACE ("ACE_Message_Queue::low_water_mark"); + ACE_TRACE ("ACE_Message_Queue::low_water_mark"); ACE_GUARD (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_); this->low_water_mark_ = lwm; } -template size_t -ACE_Message_Queue::message_bytes (void) +template size_t +ACE_Message_Queue::message_bytes (void) { - ACE_TRACE ("ACE_Message_Queue::message_bytes"); + ACE_TRACE ("ACE_Message_Queue::message_bytes"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, 0); return this->cur_bytes_; } -template size_t -ACE_Message_Queue::message_length (void) +template size_t +ACE_Message_Queue::message_length (void) { - ACE_TRACE ("ACE_Message_Queue::message_length"); + ACE_TRACE ("ACE_Message_Queue::message_length"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, 0); return this->cur_length_; } -template size_t -ACE_Message_Queue::message_count (void) +template size_t +ACE_Message_Queue::message_count (void) { - ACE_TRACE ("ACE_Message_Queue::message_count"); + ACE_TRACE ("ACE_Message_Queue::message_count"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, 0); return this->cur_count_; } -template int -ACE_Message_Queue::deactivate () +template int +ACE_Message_Queue::deactivate () { - ACE_TRACE ("ACE_Message_Queue::deactivate"); + ACE_TRACE ("ACE_Message_Queue::deactivate"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); return this->deactivate_i (0); // Not a pulse } -template int -ACE_Message_Queue::activate (void) +template int +ACE_Message_Queue::activate (void) { - ACE_TRACE ("ACE_Message_Queue::activate"); + ACE_TRACE ("ACE_Message_Queue::activate"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); return this->activate_i (); } -template int -ACE_Message_Queue::pulse () +template int +ACE_Message_Queue::pulse () { - ACE_TRACE ("ACE_Message_Queue::pulse"); + ACE_TRACE ("ACE_Message_Queue::pulse"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); return this->deactivate_i (1); // Just a pulse } -template int -ACE_Message_Queue::deactivated (void) +template int +ACE_Message_Queue::deactivated (void) { - ACE_TRACE ("ACE_Message_Queue::deactivated"); + ACE_TRACE ("ACE_Message_Queue::deactivated"); return this->state_ == ACE_Message_Queue_Base::DEACTIVATED; } -template int -ACE_Message_Queue::state (void) +template int +ACE_Message_Queue::state (void) { - ACE_TRACE ("ACE_Message_Queue::state"); + ACE_TRACE ("ACE_Message_Queue::state"); return this->state_; } -template ACE_SYNCH_MUTEX_T & -ACE_Message_Queue::lock (void) +template ACE_SYNCH_MUTEX_T & +ACE_Message_Queue::lock (void) { return this->lock_; } -template void -ACE_Message_Queue::dump (void) const +template +ACE_Time_Value_T +ACE_Message_Queue::gettimeofday (void) const +{ + return this->time_policy_ (); +} + +template +void +ACE_Message_Queue::set_time_policy (TIME_POLICY const & rhs) +{ + this->time_policy_ = rhs; +} + +template void +ACE_Message_Queue::dump (void) const { #if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Message_Queue::dump"); + ACE_TRACE ("ACE_Message_Queue::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); switch (this->state_) { @@ -994,32 +1023,32 @@ ACE_Message_Queue::dump (void) const #endif /* ACE_HAS_DUMP */ } -template void -ACE_Message_Queue::message_bytes (size_t new_value) +template void +ACE_Message_Queue::message_bytes (size_t new_value) { - ACE_TRACE ("ACE_Message_Queue::message_bytes"); + ACE_TRACE ("ACE_Message_Queue::message_bytes"); ACE_GUARD (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_); this->cur_bytes_ = new_value; } -template void -ACE_Message_Queue::message_length (size_t new_value) +template void +ACE_Message_Queue::message_length (size_t new_value) { - ACE_TRACE ("ACE_Message_Queue::message_length"); + ACE_TRACE ("ACE_Message_Queue::message_length"); ACE_GUARD (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_); this->cur_length_ = new_value; } -template -ACE_Message_Queue::ACE_Message_Queue (size_t hwm, +template +ACE_Message_Queue::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 ()) + , not_full_cond_ (lock_, ACE_Condition_Attributes_T ()) { - ACE_TRACE ("ACE_Message_Queue::ACE_Message_Queue"); + ACE_TRACE ("ACE_Message_Queue::ACE_Message_Queue"); if (this->open (hwm, lwm, ns) == -1) ACE_ERROR ((LM_ERROR, @@ -1048,10 +1077,10 @@ ACE_Message_Queue::ACE_Message_Queue (size_t hwm, #endif /* ACE_HAS_MONITOR_POINTS==1 */ } -template -ACE_Message_Queue::~ACE_Message_Queue (void) +template +ACE_Message_Queue::~ACE_Message_Queue (void) { - ACE_TRACE ("ACE_Message_Queue::~ACE_Message_Queue"); + ACE_TRACE ("ACE_Message_Queue::~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_Message_Queue (void) #endif /* ACE_HAS_MONITOR_POINTS==1 */ } -template int -ACE_Message_Queue::flush_i (void) +template int +ACE_Message_Queue::flush_i (void) { int number_flushed = 0; @@ -1105,12 +1134,12 @@ ACE_Message_Queue::flush_i (void) // once for the same queue, we're in bigger trouble than just // concurrency control! -template int -ACE_Message_Queue::open (size_t hwm, +template int +ACE_Message_Queue::open (size_t hwm, size_t lwm, ACE_Notification_Strategy *ns) { - ACE_TRACE ("ACE_Message_Queue::open"); + ACE_TRACE ("ACE_Message_Queue::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::open (size_t hwm, // Implementation of the public deactivate() method // (assumes locks are held). -template int -ACE_Message_Queue::deactivate_i (int pulse) +template int +ACE_Message_Queue::deactivate_i (int pulse) { - ACE_TRACE ("ACE_Message_Queue::deactivate_i"); + ACE_TRACE ("ACE_Message_Queue::deactivate_i"); int const previous_state = this->state_; if (previous_state != ACE_Message_Queue_Base::DEACTIVATED) @@ -1147,19 +1176,19 @@ ACE_Message_Queue::deactivate_i (int pulse) return previous_state; } -template int -ACE_Message_Queue::activate_i (void) +template int +ACE_Message_Queue::activate_i (void) { - ACE_TRACE ("ACE_Message_Queue::activate_i"); + ACE_TRACE ("ACE_Message_Queue::activate_i"); int const previous_state = this->state_; this->state_ = ACE_Message_Queue_Base::ACTIVATED; return previous_state; } -template int -ACE_Message_Queue::flush (void) +template int +ACE_Message_Queue::flush (void) { - ACE_TRACE ("ACE_Message_Queue::flush"); + ACE_TRACE ("ACE_Message_Queue::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::flush (void) // Clean up the queue if we have not already done so! -template int -ACE_Message_Queue::close (void) +template int +ACE_Message_Queue::close (void) { - ACE_TRACE ("ACE_Message_Queue::close"); + ACE_TRACE ("ACE_Message_Queue::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::close (void) return this->flush_i (); } -template int -ACE_Message_Queue::signal_enqueue_waiters (void) +template int +ACE_Message_Queue::signal_enqueue_waiters (void) { if (this->not_full_cond_.signal () != 0) return -1; return 0; } -template int -ACE_Message_Queue::signal_dequeue_waiters (void) +template int +ACE_Message_Queue::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::signal_dequeue_waiters (void) // Actually put the node at the end (no locking so must be called with // locks held). -template int -ACE_Message_Queue::enqueue_tail_i (ACE_Message_Block *new_item) +template int +ACE_Message_Queue::enqueue_tail_i (ACE_Message_Block *new_item) { - ACE_TRACE ("ACE_Message_Queue::enqueue_tail_i"); + ACE_TRACE ("ACE_Message_Queue::enqueue_tail_i"); if (new_item == 0) return -1; @@ -1253,10 +1282,10 @@ ACE_Message_Queue::enqueue_tail_i (ACE_Message_Block *new_item) // Actually put the node(s) at the head (no locking) -template int -ACE_Message_Queue::enqueue_head_i (ACE_Message_Block *new_item) +template int +ACE_Message_Queue::enqueue_head_i (ACE_Message_Block *new_item) { - ACE_TRACE ("ACE_Message_Queue::enqueue_head_i"); + ACE_TRACE ("ACE_Message_Queue::enqueue_head_i"); if (new_item == 0) return -1; @@ -1298,10 +1327,10 @@ ACE_Message_Queue::enqueue_head_i (ACE_Message_Block *new_item) // Actually put the node at its proper position relative to its // priority. -template int -ACE_Message_Queue::enqueue_i (ACE_Message_Block *new_item) +template int +ACE_Message_Queue::enqueue_i (ACE_Message_Block *new_item) { - ACE_TRACE ("ACE_Message_Queue::enqueue_i"); + ACE_TRACE ("ACE_Message_Queue::enqueue_i"); if (new_item == 0) return -1; @@ -1369,11 +1398,11 @@ ACE_Message_Queue::enqueue_i (ACE_Message_Block *new_item) // Actually put the node at its proper position relative to its // deadline time. -template int -ACE_Message_Queue::enqueue_deadline_i (ACE_Message_Block *new_item) +template int +ACE_Message_Queue::enqueue_deadline_i (ACE_Message_Block *new_item) { #if defined (ACE_HAS_TIMED_MESSAGE_BLOCKS) - ACE_TRACE ("ACE_Message_Queue::enqueue_deadline_i"); + ACE_TRACE ("ACE_Message_Queue::enqueue_deadline_i"); if (new_item == 0) return -1; @@ -1440,14 +1469,14 @@ ACE_Message_Queue::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 int -ACE_Message_Queue::dequeue_head_i (ACE_Message_Block *&first_item) +template int +ACE_Message_Queue::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::dequeue_head_i"); + ACE_TRACE ("ACE_Message_Queue::dequeue_head_i"); first_item = this->head_; this->head_ = this->head_->next (); @@ -1491,10 +1520,10 @@ ACE_Message_Queue::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 int -ACE_Message_Queue::dequeue_prio_i (ACE_Message_Block *&dequeued) +template int +ACE_Message_Queue::dequeue_prio_i (ACE_Message_Block *&dequeued) { - ACE_TRACE ("ACE_Message_Queue::dequeue_prio_i"); + ACE_TRACE ("ACE_Message_Queue::dequeue_prio_i"); if (this->head_ == 0) return -1; @@ -1566,14 +1595,14 @@ ACE_Message_Queue::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 int -ACE_Message_Queue::dequeue_tail_i (ACE_Message_Block *&dequeued) +template int +ACE_Message_Queue::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::dequeue_tail_i"); + ACE_TRACE ("ACE_Message_Queue::dequeue_tail_i"); dequeued = this->tail_; if (this->tail_->prev () == 0) { @@ -1615,15 +1644,15 @@ ACE_Message_Queue::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 int -ACE_Message_Queue::dequeue_deadline_i (ACE_Message_Block *&dequeued) +template int +ACE_Message_Queue::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::dequeue_deadline_i"); + ACE_TRACE ("ACE_Message_Queue::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::dequeue_deadline_i (ACE_Message_Block *&dequeu // Take a look at the first item without removing it. -template int -ACE_Message_Queue::peek_dequeue_head (ACE_Message_Block *&first_item, +template int +ACE_Message_Queue::peek_dequeue_head (ACE_Message_Block *&first_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue::peek_dequeue_head"); + ACE_TRACE ("ACE_Message_Queue::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::peek_dequeue_head (ACE_Message_Block *&first_i return ACE_Utils::truncate_cast (this->cur_count_); } -template int -ACE_Message_Queue::wait_not_full_cond (ACE_Time_Value *timeout) +template int +ACE_Message_Queue::wait_not_full_cond (ACE_Time_Value *timeout) { int result = 0; @@ -1732,8 +1761,8 @@ ACE_Message_Queue::wait_not_full_cond (ACE_Time_Value *timeout) return result; } -template int -ACE_Message_Queue::wait_not_empty_cond (ACE_Time_Value *timeout) +template int +ACE_Message_Queue::wait_not_empty_cond (ACE_Time_Value *timeout) { int result = 0; @@ -1761,11 +1790,11 @@ ACE_Message_Queue::wait_not_empty_cond (ACE_Time_Value *timeout) // Block indefinitely waiting for an item to arrive, does not ignore // alerts (e.g., signals). -template int -ACE_Message_Queue::enqueue_head (ACE_Message_Block *new_item, +template int +ACE_Message_Queue::enqueue_head (ACE_Message_Block *new_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue::enqueue_head"); + ACE_TRACE ("ACE_Message_Queue::enqueue_head"); int queue_count = 0; ACE_Notification_Strategy *notifier = 0; { @@ -1799,11 +1828,11 @@ ACE_Message_Queue::enqueue_head (ACE_Message_Block *new_item, // accordance with its (0 is lowest priority). Returns // -1 on failure, else the number of items still on the queue. -template int -ACE_Message_Queue::enqueue_prio (ACE_Message_Block *new_item, +template int +ACE_Message_Queue::enqueue_prio (ACE_Message_Block *new_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue::enqueue_prio"); + ACE_TRACE ("ACE_Message_Queue::enqueue_prio"); int queue_count = 0; ACE_Notification_Strategy *notifier = 0; { @@ -1837,11 +1866,11 @@ ACE_Message_Queue::enqueue_prio (ACE_Message_Block *new_item, // accordance with its . Returns // -1 on failure, else the number of items still on the queue. -template int -ACE_Message_Queue::enqueue_deadline (ACE_Message_Block *new_item, +template int +ACE_Message_Queue::enqueue_deadline (ACE_Message_Block *new_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue::enqueue_deadline"); + ACE_TRACE ("ACE_Message_Queue::enqueue_deadline"); int queue_count = 0; ACE_Notification_Strategy *notifier = 0; { @@ -1871,22 +1900,22 @@ ACE_Message_Queue::enqueue_deadline (ACE_Message_Block *new_item, return queue_count; } -template int -ACE_Message_Queue::enqueue (ACE_Message_Block *new_item, +template int +ACE_Message_Queue::enqueue (ACE_Message_Block *new_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue::enqueue"); + ACE_TRACE ("ACE_Message_Queue::enqueue"); return this->enqueue_prio (new_item, timeout); } // Block indefinitely waiting for an item to arrive, // does not ignore alerts (e.g., signals). -template int -ACE_Message_Queue::enqueue_tail (ACE_Message_Block *new_item, +template int +ACE_Message_Queue::enqueue_tail (ACE_Message_Block *new_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue::enqueue_tail"); + ACE_TRACE ("ACE_Message_Queue::enqueue_tail"); int queue_count = 0; ACE_Notification_Strategy *notifier = 0; { @@ -1920,11 +1949,11 @@ ACE_Message_Queue::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 int -ACE_Message_Queue::dequeue_head (ACE_Message_Block *&first_item, +template int +ACE_Message_Queue::dequeue_head (ACE_Message_Block *&first_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue::dequeue_head"); + ACE_TRACE ("ACE_Message_Queue::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::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 int -ACE_Message_Queue::dequeue_prio (ACE_Message_Block *&dequeued, +template int +ACE_Message_Queue::dequeue_prio (ACE_Message_Block *&dequeued, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue::dequeue_prio"); + ACE_TRACE ("ACE_Message_Queue::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::dequeue_prio (ACE_Message_Block *&dequeued, // indefinitely (or until an alert occurs). Otherwise, block for upto // the amount of time specified by timeout. -template int -ACE_Message_Queue::dequeue_tail (ACE_Message_Block *&dequeued, +template int +ACE_Message_Queue::dequeue_tail (ACE_Message_Block *&dequeued, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue::dequeue_tail"); + ACE_TRACE ("ACE_Message_Queue::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::dequeue_tail (ACE_Message_Block *&dequeued, // indefinitely (or until an alert occurs). Otherwise, block for upto // the amount of time specified by timeout. -template int -ACE_Message_Queue::dequeue_deadline (ACE_Message_Block *&dequeued, +template int +ACE_Message_Queue::dequeue_deadline (ACE_Message_Block *&dequeued, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Message_Queue::dequeue_deadline"); + ACE_TRACE ("ACE_Message_Queue::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::dequeue_deadline (ACE_Message_Block *&dequeued return this->dequeue_deadline_i (dequeued); } -template int -ACE_Message_Queue::notify (void) +template int +ACE_Message_Queue::notify (void) { - ACE_TRACE ("ACE_Message_Queue::notify"); + ACE_TRACE ("ACE_Message_Queue::notify"); // By default, don't do anything. if (this->notification_strategy_ == 0) @@ -2021,12 +2050,12 @@ ACE_Message_Queue::notify (void) } // = Initialization and termination methods. -template -ACE_Dynamic_Message_Queue::ACE_Dynamic_Message_Queue (ACE_Dynamic_Message_Strategy & message_strategy, +template +ACE_Dynamic_Message_Queue::ACE_Dynamic_Message_Queue (ACE_Dynamic_Message_Strategy & message_strategy, size_t hwm, size_t lwm, ACE_Notification_Strategy *ns) - : ACE_Message_Queue (hwm, lwm, ns), + : ACE_Message_Queue (hwm, lwm, ns), pending_head_ (0), pending_tail_ (0), late_head_ (0), @@ -2042,14 +2071,14 @@ ACE_Dynamic_Message_Queue::ACE_Dynamic_Message_Queue (ACE_Dynamic // dtor: free message strategy and let base class dtor do the rest. -template -ACE_Dynamic_Message_Queue::~ACE_Dynamic_Message_Queue (void) +template +ACE_Dynamic_Message_Queue::~ACE_Dynamic_Message_Queue (void) { delete &this->message_strategy_; } -template int -ACE_Dynamic_Message_Queue::remove_messages (ACE_Message_Block *&list_head, +template int +ACE_Dynamic_Message_Queue::remove_messages (ACE_Message_Block *&list_head, ACE_Message_Block *&list_tail, u_int status_flags) { @@ -2188,11 +2217,11 @@ ACE_Dynamic_Message_Queue::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 int -ACE_Dynamic_Message_Queue::dequeue_head (ACE_Message_Block *&first_item, +template int +ACE_Dynamic_Message_Queue::dequeue_head (ACE_Message_Block *&first_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Dynamic_Message_Queue::dequeue_head"); + ACE_TRACE ("ACE_Dynamic_Message_Queue::dequeue_head"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); @@ -2228,15 +2257,15 @@ ACE_Dynamic_Message_Queue::dequeue_head (ACE_Message_Block *&firs // Dequeue and return the at the (logical) head // of the queue. -template void -ACE_Dynamic_Message_Queue::dump (void) const +template void +ACE_Dynamic_Message_Queue::dump (void) const { #if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Dynamic_Message_Queue::dump"); + ACE_TRACE ("ACE_Dynamic_Message_Queue::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Message_Queue (base class):\n"))); - this->ACE_Message_Queue::dump (); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Message_Queue (base class):\n"))); + this->ACE_Message_Queue::dump (); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("pending_head_ = %u\n") @@ -2260,10 +2289,10 @@ ACE_Dynamic_Message_Queue::dump (void) const } // dump the state of the queue -template int -ACE_Dynamic_Message_Queue::enqueue_i (ACE_Message_Block *new_item) +template int +ACE_Dynamic_Message_Queue::enqueue_i (ACE_Message_Block *new_item) { - ACE_TRACE ("ACE_Dynamic_Message_Queue::enqueue_i"); + ACE_TRACE ("ACE_Dynamic_Message_Queue::enqueue_i"); if (new_item == 0) { @@ -2415,8 +2444,8 @@ ACE_Dynamic_Message_Queue::enqueue_i (ACE_Message_Block *new_item // Message Queue constructor to update the priorities of all enqueued // messages. -template int -ACE_Dynamic_Message_Queue::sublist_enqueue_i (ACE_Message_Block *new_item, +template int +ACE_Dynamic_Message_Queue::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::sublist_enqueue_i (ACE_Message_Block * // Enqueue a message in priority order within a given priority status // sublist. -template int -ACE_Dynamic_Message_Queue::dequeue_head_i (ACE_Message_Block *&first_item) +template int +ACE_Dynamic_Message_Queue::dequeue_head_i (ACE_Message_Block *&first_item) { - ACE_TRACE ("ACE_Dynamic_Message_Queue::dequeue_head_i"); + ACE_TRACE ("ACE_Dynamic_Message_Queue::dequeue_head_i"); int result = 0; int last_in_subqueue = 0; @@ -2615,8 +2644,8 @@ ACE_Dynamic_Message_Queue::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 int -ACE_Dynamic_Message_Queue::refresh_queue (const ACE_Time_Value ¤t_time) +template int +ACE_Dynamic_Message_Queue::refresh_queue (const ACE_Time_Value ¤t_time) { int result; @@ -2631,8 +2660,8 @@ ACE_Dynamic_Message_Queue::refresh_queue (const ACE_Time_Value &c // Refresh the queue using the strategy specific priority status // function. -template int -ACE_Dynamic_Message_Queue::refresh_pending_queue (const ACE_Time_Value ¤t_time) +template int +ACE_Dynamic_Message_Queue::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::refresh_pending_queue (const ACE_Time_ // Refresh the pending queue using the strategy specific priority // status function. -template int -ACE_Dynamic_Message_Queue::refresh_late_queue (const ACE_Time_Value ¤t_time) +template int +ACE_Dynamic_Message_Queue::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::refresh_late_queue (const ACE_Time_Val // Refresh the late queue using the strategy specific priority status // function. -template int -ACE_Dynamic_Message_Queue::peek_dequeue_head (ACE_Message_Block *&first_item, +template int +ACE_Dynamic_Message_Queue::peek_dequeue_head (ACE_Message_Block *&first_item, ACE_Time_Value *timeout) { - return ACE_Message_Queue::peek_dequeue_head (first_item, + return ACE_Message_Queue::peek_dequeue_head (first_item, timeout); } // Private method to hide public base class method: just calls base // class method. -template int -ACE_Dynamic_Message_Queue::enqueue_tail (ACE_Message_Block *new_item, +template int +ACE_Dynamic_Message_Queue::enqueue_tail (ACE_Message_Block *new_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Dynamic_Message_Queue::enqueue_tail"); + ACE_TRACE ("ACE_Dynamic_Message_Queue::enqueue_tail"); return this->enqueue_prio (new_item, timeout); } @@ -2863,11 +2892,11 @@ ACE_Dynamic_Message_Queue::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 int -ACE_Dynamic_Message_Queue::enqueue_head (ACE_Message_Block *new_item, +template int +ACE_Dynamic_Message_Queue::enqueue_head (ACE_Message_Block *new_item, ACE_Time_Value *timeout) { - ACE_TRACE ("ACE_Dynamic_Message_Queue::enqueue_head"); + ACE_TRACE ("ACE_Dynamic_Message_Queue::enqueue_head"); return this->enqueue_prio (new_item, timeout); } @@ -2876,25 +2905,26 @@ ACE_Dynamic_Message_Queue::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_Message_Queue * -ACE_Message_Queue_Factory::create_static_message_queue (size_t hwm, +template +ACE_Message_Queue * +ACE_Message_Queue_Factory::create_static_message_queue (size_t hwm, size_t lwm, ACE_Notification_Strategy *ns) { - ACE_Message_Queue *tmp = 0; + typedef ACE_Message_Queue QUEUE_TYPE; + QUEUE_TYPE *tmp = 0; ACE_NEW_RETURN (tmp, - ACE_Message_Queue (hwm, lwm, ns), + QUEUE_TYPE (hwm, lwm, ns), 0); return tmp; } // Factory method for a statically prioritized ACE_Message_Queue. -template -ACE_Dynamic_Message_Queue * -ACE_Message_Queue_Factory::create_deadline_message_queue (size_t hwm, +template +ACE_Dynamic_Message_Queue * +ACE_Message_Queue_Factory::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::create_deadline_message_queue (size_t dynamic_priority_offset), 0); - ACE_Dynamic_Message_Queue *tmp = 0; + typedef ACE_Dynamic_Message_Queue QUEUE_TYPE; + QUEUE_TYPE *tmp = 0; ACE_NEW_RETURN (tmp, - ACE_Dynamic_Message_Queue (*adms, hwm, lwm, ns), + QUEUE_TYPE (*adms, hwm, lwm, ns), 0); return tmp; } @@ -2921,9 +2952,9 @@ ACE_Message_Queue_Factory::create_deadline_message_queue (size_t // Factory method for a dynamically prioritized (by time to deadline) // ACE_Dynamic_Message_Queue. -template -ACE_Dynamic_Message_Queue * -ACE_Message_Queue_Factory::create_laxity_message_queue (size_t hwm, +template +ACE_Dynamic_Message_Queue * +ACE_Message_Queue_Factory::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::create_laxity_message_queue (size_t hw dynamic_priority_offset), 0); - ACE_Dynamic_Message_Queue *tmp = 0; + typedef ACE_Dynamic_Message_Queue QUEUE_TYPE; + QUEUE_TYPE *tmp = 0; ACE_NEW_RETURN (tmp, - ACE_Dynamic_Message_Queue (*alms, hwm, lwm, ns), + QUEUE_TYPE (*alms, hwm, lwm, ns), 0); return tmp; } @@ -2953,9 +2985,9 @@ ACE_Message_Queue_Factory::create_laxity_message_queue (size_t hw #if defined (ACE_VXWORKS) // factory method for a wrapped VxWorks message queue -template +template ACE_Message_Queue_Vx * -ACE_Message_Queue_Factory::create_Vx_message_queue (size_t max_messages, +ACE_Message_Queue_Factory::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::create_Vx_message_queue (size_t max_me #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) -template +template ACE_Message_Queue_NT * -ACE_Message_Queue_Factory::create_NT_message_queue (size_t max_threads) +ACE_Message_Queue_Factory::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 +template class ACE_Message_Queue : public ACE_Message_Queue_Base { public: - friend class ACE_Message_Queue_Iterator; - friend class ACE_Message_Queue_Reverse_Iterator; + friend class ACE_Message_Queue_Iterator; + friend class ACE_Message_Queue_Reverse_Iterator; // = Traits - typedef ACE_Message_Queue_Iterator + typedef ACE_Message_Queue_Iterator ITERATOR; - typedef ACE_Message_Queue_Reverse_Iterator + typedef ACE_Message_Queue_Reverse_Iterator 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 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_DEFAULT_MESSAGE_QUEUE_TYPE; * * @brief Iterator for the ACE_Message_Queue. */ -template +template class ACE_Message_Queue_Iterator { public: // = Initialization method. - ACE_Message_Queue_Iterator (ACE_Message_Queue &queue); + ACE_Message_Queue_Iterator (ACE_Message_Queue &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 &queue_; + ACE_Message_Queue &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 +template class ACE_Message_Queue_Reverse_Iterator { public: // = Initialization method. - ACE_Message_Queue_Reverse_Iterator (ACE_Message_Queue &queue); + ACE_Message_Queue_Reverse_Iterator (ACE_Message_Queue &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 &queue_; + ACE_Message_Queue &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 -class ACE_Dynamic_Message_Queue : public ACE_Message_Queue +template +class ACE_Dynamic_Message_Queue : public ACE_Message_Queue { 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_UNIMPLEMENTED_FUNC (ACE_Dynamic_Message_Queue (const ACE_Dynamic_Message_Queue &)) + ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Dynamic_Message_Queue &)) + ACE_UNIMPLEMENTED_FUNC (ACE_Dynamic_Message_Queue (const ACE_Dynamic_Message_Queue &)) // 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 +template class ACE_Message_Queue_Factory { public: /// Factory method for a statically prioritized ACE_Message_Queue - static ACE_Message_Queue * + static ACE_Message_Queue * 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 * + static ACE_Dynamic_Message_Queue * 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 * + static ACE_Dynamic_Message_Queue * 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_Queue_Ex_Iterator; -template class ACE_Message_Queue_Ex_Reverse_Iterator; +template class ACE_Message_Queue_Ex_Iterator; +template class ACE_Message_Queue_Ex_Reverse_Iterator; /** * @class ACE_Message_Queue_Ex @@ -979,7 +992,7 @@ template class ACE_Message_Queue_Ex_Rev * -# ACE_MT_SYNCH: all operations are thread-safe * -# ACE_NULL_SYNCH: no synchronization and no locking overhead */ -template +template class ACE_Message_Queue_Ex { public: @@ -990,13 +1003,13 @@ public: DEFAULT_PRIORITY = 0 }; - friend class ACE_Message_Queue_Ex_Iterator ; - friend class ACE_Message_Queue_Ex_Reverse_Iterator; + friend class ACE_Message_Queue_Ex_Iterator ; + friend class ACE_Message_Queue_Ex_Reverse_Iterator; // = Traits - typedef ACE_Message_Queue_Ex_Iterator + typedef ACE_Message_Queue_Ex_Iterator ITERATOR; - typedef ACE_Message_Queue_Ex_Reverse_Iterator + typedef ACE_Message_Queue_Ex_Reverse_Iterator 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 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 queue_; + ACE_Message_Queue queue_; }; /** @@ -1381,12 +1402,12 @@ protected: * * @brief Iterator for the ACE_Message_Queue_Ex. */ -template +template class ACE_Message_Queue_Ex_Iterator { public: // = Initialization method. - ACE_Message_Queue_Ex_Iterator (ACE_Message_Queue_Ex & queue); + ACE_Message_Queue_Ex_Iterator (ACE_Message_Queue_Ex & 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 iter_; + ACE_Message_Queue_Iterator iter_; }; /** @@ -1416,12 +1437,12 @@ private: * * @brief Reverse iterator for the ACE_Message_Queue_Ex. */ -template +template class ACE_Message_Queue_Ex_Reverse_Iterator { public: // = Initialization method. - ACE_Message_Queue_Ex_Reverse_Iterator (ACE_Message_Queue_Ex & queue); + ACE_Message_Queue_Ex_Reverse_Iterator (ACE_Message_Queue_Ex & 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 iter_; + ACE_Message_Queue_Reverse_Iterator 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_Queue_Ex_N : public ACE_Message_Queue_Ex +template +class ACE_Message_Queue_Ex_N : public ACE_Message_Queue_Ex { 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 void -ACE_Module::dump (void) const +template void +ACE_Module::dump (void) const { #if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Module::dump"); + ACE_TRACE ("ACE_Module::dump"); #endif /* ACE_HAS_DUMP */ } -template void -ACE_Module::writer (ACE_Task *q, +template void +ACE_Module::writer (ACE_Task *q, int flags /* = M_DELETE_WRITER */) { - ACE_TRACE ("ACE_Module::writer"); + ACE_TRACE ("ACE_Module::writer"); // Close and maybe delete old writer this->close_i (1, flags); @@ -49,11 +49,11 @@ ACE_Module::writer (ACE_Task *q, ACE_SET_BITS (flags_, (flags & M_DELETE_WRITER)); } -template void -ACE_Module::reader (ACE_Task *q, +template void +ACE_Module::reader (ACE_Task *q, int flags /* = M_DELETE_READER */) { - ACE_TRACE ("ACE_Module::reader"); + ACE_TRACE ("ACE_Module::reader"); // Close and maybe delete old writer this->close_i (0, flags); @@ -73,23 +73,23 @@ ACE_Module::reader (ACE_Task *q, // Link this ACE_Module on top of ACE_Module M. -template void -ACE_Module::link (ACE_Module *m) +template void +ACE_Module::link (ACE_Module *m) { - ACE_TRACE ("ACE_Module::link"); + ACE_TRACE ("ACE_Module::link"); this->next (m); this->writer ()->next (m->writer ()); m->reader ()->next (this->reader ()); } -template int -ACE_Module::open (const ACE_TCHAR *module_name, - ACE_Task *writer_q, - ACE_Task *reader_q, +template int +ACE_Module::open (const ACE_TCHAR *module_name, + ACE_Task *writer_q, + ACE_Task *reader_q, void *arg, int flags /* = M_DELETE */) { - ACE_TRACE ("ACE_Module::open"); + ACE_TRACE ("ACE_Module::open"); this->name (module_name); this->arg_ = arg; @@ -102,16 +102,18 @@ ACE_Module::open (const ACE_TCHAR *module_name, if (writer_q == 0) { + typedef ACE_Thru_Task TASK_TYPE; ACE_NEW_RETURN (writer_q, - ACE_Thru_Task, + TASK_TYPE, -1); ACE_SET_BITS (flags, M_DELETE_WRITER); } if (reader_q == 0) { + typedef ACE_Thru_Task TASK_TYPE; ACE_NEW_RETURN (reader_q, - ACE_Thru_Task, + TASK_TYPE, -1); ACE_SET_BITS (flags, M_DELETE_READER); } @@ -144,10 +146,10 @@ ACE_Module::open (const ACE_TCHAR *module_name, // Set and get pointer to sibling ACE_Task in ACE_Module. -template ACE_Task * -ACE_Module::sibling (ACE_Task *orig) +template ACE_Task * +ACE_Module::sibling (ACE_Task *orig) { - ACE_TRACE ("ACE_Module::sibling"); + ACE_TRACE ("ACE_Module::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::sibling (ACE_Task *orig) return 0; } -template -ACE_Module::ACE_Module (void) +template +ACE_Module::ACE_Module (void) : next_ (0) , arg_ (0) , flags_ (M_FLAGS_NOT_SET) { - ACE_TRACE ("ACE_Module::ACE_Module"); + ACE_TRACE ("ACE_Module::ACE_Module"); this->name (ACE_TEXT ("")); // Do nothing... this->q_pair_[0] = 0; this->q_pair_[1] = 0; } -template -ACE_Module::~ACE_Module (void) +template +ACE_Module::~ACE_Module (void) { - ACE_TRACE ("ACE_Module::~ACE_Module"); + ACE_TRACE ("ACE_Module::~ACE_Module"); // Only close down if we haven't already done so. if (this->reader () || this->writer ()) this->close (); } -template -ACE_Module::ACE_Module (const ACE_TCHAR *module_name, - ACE_Task *writer_q, - ACE_Task *reader_q, +template +ACE_Module::ACE_Module (const ACE_TCHAR *module_name, + ACE_Task *writer_q, + ACE_Task *reader_q, void *args, int flags /* = M_DELETE */) : flags_ (M_FLAGS_NOT_SET) { - ACE_TRACE ("ACE_Module::ACE_Module"); + ACE_TRACE ("ACE_Module::ACE_Module"); this->q_pair_[0] = 0; this->q_pair_[1] = 0; @@ -198,10 +200,10 @@ ACE_Module::ACE_Module (const ACE_TCHAR *module_name, ACE_TEXT ("ACE_Module"))); } -template int -ACE_Module::close (int flags /* = M_DELETE_NONE */) +template int +ACE_Module::close (int flags /* = M_DELETE_NONE */) { - ACE_TRACE ("ACE_Module::close"); + ACE_TRACE ("ACE_Module::close"); int result = 0; @@ -219,18 +221,18 @@ ACE_Module::close (int flags /* = M_DELETE_NONE */) return result; } -template int -ACE_Module::close_i (int which, +template int +ACE_Module::close_i (int which, int flags) { - ACE_TRACE ("ACE_Module::close_i"); + ACE_TRACE ("ACE_Module::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 *task = this->q_pair_[which]; + ACE_Task *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 +template 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 *writer = 0, - ACE_Task *reader = 0, + ACE_Task *writer = 0, + ACE_Task *reader = 0, void *args = 0, int flags = M_DELETE); @@ -101,8 +101,8 @@ public: * . */ int open (const ACE_TCHAR *module_name, - ACE_Task *writer = 0, - ACE_Task *reader = 0, + ACE_Task *writer = 0, + ACE_Task *reader = 0, void *a = 0, int flags = M_DELETE); @@ -117,7 +117,7 @@ public: // = ACE_Task manipulation routines /// Get the writer task. - ACE_Task *writer (void); + ACE_Task *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 . */ - void writer (ACE_Task *q, int flags = M_DELETE_WRITER); + void writer (ACE_Task *q, int flags = M_DELETE_WRITER); /// Get the reader task. - ACE_Task *reader (void); + ACE_Task *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 . */ - void reader (ACE_Task *q, int flags = M_DELETE_READER); + void reader (ACE_Task *q, int flags = M_DELETE_READER); /// Set and get pointer to sibling ACE_Task in an ACE_Module - ACE_Task *sibling (ACE_Task *orig); + ACE_Task *sibling (ACE_Task *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 *m); + void link (ACE_Module *m); /// Get the next pointer to the module above in the stream. - ACE_Module *next (void); + ACE_Module *next (void); /// Set the next pointer to the module above in the stream. - void next (ACE_Module *m); + void next (ACE_Module *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 *q_pair_[2]; + ACE_Task *q_pair_[2]; /// Name of the ACE_Module. ACE_TCHAR name_[MAXPATHLEN + 1]; /// Next ACE_Module in the stack. - ACE_Module *next_; + ACE_Module *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_INLINE void * -ACE_Module::arg (void) const +template ACE_INLINE void * +ACE_Module::arg (void) const { - ACE_TRACE ("ACE_Module::arg"); + ACE_TRACE ("ACE_Module::arg"); return this->arg_; } -template ACE_INLINE void -ACE_Module::arg (void *a) +template ACE_INLINE void +ACE_Module::arg (void *a) { - ACE_TRACE ("ACE_Module::arg"); + ACE_TRACE ("ACE_Module::arg"); this->arg_ = a; } -template ACE_INLINE const ACE_TCHAR * -ACE_Module::name (void) const +template ACE_INLINE const ACE_TCHAR * +ACE_Module::name (void) const { - ACE_TRACE ("ACE_Module::name"); + ACE_TRACE ("ACE_Module::name"); return this->name_; } -template ACE_INLINE void -ACE_Module::name (const ACE_TCHAR *n) +template ACE_INLINE void +ACE_Module::name (const ACE_TCHAR *n) { - ACE_TRACE ("ACE_Module::name"); + ACE_TRACE ("ACE_Module::name"); ACE_OS::strsncpy (this->name_, n, MAXPATHLEN); } -template ACE_INLINE ACE_Task * -ACE_Module::writer (void) +template ACE_INLINE ACE_Task * +ACE_Module::writer (void) { - ACE_TRACE ("ACE_Module::writer"); + ACE_TRACE ("ACE_Module::writer"); return this->q_pair_[1]; } -template ACE_INLINE ACE_Task * -ACE_Module::reader (void) +template ACE_INLINE ACE_Task * +ACE_Module::reader (void) { - ACE_TRACE ("ACE_Module::reader"); + ACE_TRACE ("ACE_Module::reader"); return this->q_pair_[0]; } -template ACE_INLINE ACE_Module * -ACE_Module::next (void) +template ACE_INLINE ACE_Module * +ACE_Module::next (void) { - ACE_TRACE ("ACE_Module::next"); + ACE_TRACE ("ACE_Module::next"); return this->next_; } -template ACE_INLINE void -ACE_Module::next (ACE_Module *m) +template ACE_INLINE void +ACE_Module::next (ACE_Module *m) { - ACE_TRACE ("ACE_Module::next"); + ACE_TRACE ("ACE_Module::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 + */ +#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 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::operator()() const +{ +# if defined (ACE_WIN32) + return ACE_Time_Value_T (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(ts); + else + return ACE_Time_Value_T (ACE_Time_Value::zero); +#else + return ACE_Time_Value_T (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_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 { 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_Condition (const ACE_Condition &); }; +typedef ACE_Condition 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* 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 (*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* 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 // 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 // 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 void -ACE_Stream::dump (void) const +template void +ACE_Stream::dump (void) const { #if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Stream::dump"); + ACE_TRACE ("ACE_Stream::dump"); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("-------- module links --------\n"))); - for (ACE_Module *mp = this->stream_head_; + for (ACE_Module *mp = this->stream_head_; ; mp = mp->next ()) { @@ -43,7 +43,7 @@ ACE_Stream::dump (void) const ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("-------- writer links --------\n"))); - ACE_Task *tp; + ACE_Task *tp; for (tp = this->stream_head_->writer (); ; @@ -72,10 +72,10 @@ ACE_Stream::dump (void) const #endif /* ACE_HAS_DUMP */ } -template int -ACE_Stream::push (ACE_Module *new_top) +template int +ACE_Stream::push (ACE_Module *new_top) { - ACE_TRACE ("ACE_Stream::push"); + ACE_TRACE ("ACE_Stream::push"); if (this->push_module (new_top, this->stream_head_->next (), this->stream_head_) == -1) @@ -84,27 +84,27 @@ ACE_Stream::push (ACE_Module *new_top) return 0; } -template int -ACE_Stream::put (ACE_Message_Block *mb, ACE_Time_Value *tv) +template int +ACE_Stream::put (ACE_Message_Block *mb, ACE_Time_Value *tv) { - ACE_TRACE ("ACE_Stream::put"); + ACE_TRACE ("ACE_Stream::put"); return this->stream_head_->writer ()->put (mb, tv); } -template int -ACE_Stream::get (ACE_Message_Block *&mb, ACE_Time_Value *tv) +template int +ACE_Stream::get (ACE_Message_Block *&mb, ACE_Time_Value *tv) { - ACE_TRACE ("ACE_Stream::get"); + ACE_TRACE ("ACE_Stream::get"); return this->stream_head_->reader ()->getq (mb, tv); } // Return the "top" ACE_Module in a ACE_Stream, skipping over the // stream_head. -template int -ACE_Stream::top (ACE_Module *&m) +template int +ACE_Stream::top (ACE_Module *&m) { - ACE_TRACE ("ACE_Stream::top"); + ACE_TRACE ("ACE_Stream::top"); if (this->stream_head_->next () == this->stream_tail_) return -1; else @@ -114,18 +114,18 @@ ACE_Stream::top (ACE_Module *&m) } } -template int -ACE_Stream::insert (const ACE_TCHAR *prev_name, - ACE_Module *mod) +template int +ACE_Stream::insert (const ACE_TCHAR *prev_name, + ACE_Module *mod) { - ACE_TRACE ("ACE_Stream::insert"); + ACE_TRACE ("ACE_Stream::insert"); - for (ACE_Module *prev_mod = this->stream_head_; + for (ACE_Module *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 *next_mod = prev_mod->next (); + ACE_Module *next_mod = prev_mod->next (); // We can't insert a module below . if (next_mod == 0) @@ -146,20 +146,20 @@ ACE_Stream::insert (const ACE_TCHAR *prev_name, return -1; } -template int -ACE_Stream::replace (const ACE_TCHAR *replace_name, - ACE_Module *mod, +template int +ACE_Stream::replace (const ACE_TCHAR *replace_name, + ACE_Module *mod, int flags) { - ACE_TRACE ("ACE_Stream::replace"); - ACE_Module *prev_mod = 0; + ACE_TRACE ("ACE_Stream::replace"); + ACE_Module *prev_mod = 0; - for (ACE_Module *rep_mod = this->stream_head_; + for (ACE_Module *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 *next_mod = rep_mod->next (); + ACE_Module *next_mod = rep_mod->next (); if (next_mod) mod->link (next_mod); @@ -184,7 +184,7 @@ ACE_Stream::replace (const ACE_TCHAR *replace_name, if (mod->writer ()->open (mod->arg ()) == -1) return -1; - if (flags != ACE_Module::M_DELETE_NONE) + if (flags != ACE_Module::M_DELETE_NONE) { rep_mod->close (flags); delete rep_mod; @@ -201,17 +201,17 @@ ACE_Stream::replace (const ACE_TCHAR *replace_name, // Remove the "top" ACE_Module in a ACE_Stream, skipping over the // stream_head. -template int -ACE_Stream::pop (int flags) +template int +ACE_Stream::pop (int flags) { - ACE_TRACE ("ACE_Stream::pop"); + ACE_TRACE ("ACE_Stream::pop"); if (this->stream_head_->next () == this->stream_tail_) return -1; else { // Skip over the ACE_Stream head. - ACE_Module *top_mod = this->stream_head_->next (); - ACE_Module *new_top = top_mod->next (); + ACE_Module *top_mod = this->stream_head_->next (); + ACE_Module *new_top = top_mod->next (); this->stream_head_->next (new_top); @@ -220,7 +220,7 @@ ACE_Stream::pop (int flags) top_mod->close (flags); // Don't delete the Module unless the flags request this. - if (flags != ACE_Module::M_DELETE_NONE) + if (flags != ACE_Module::M_DELETE_NONE) delete top_mod; this->stream_head_->writer ()->next (new_top->writer ()); @@ -232,14 +232,14 @@ ACE_Stream::pop (int flags) // Remove a named ACE_Module from an arbitrary place in the // ACE_Stream. -template int -ACE_Stream::remove (const ACE_TCHAR *name, +template int +ACE_Stream::remove (const ACE_TCHAR *name, int flags) { - ACE_TRACE ("ACE_Stream::remove"); - ACE_Module *prev = 0; + ACE_TRACE ("ACE_Stream::remove"); + ACE_Module *prev = 0; - for (ACE_Module *mod = this->stream_head_; + for (ACE_Module *mod = this->stream_head_; mod != 0; mod = mod->next ()) { @@ -264,7 +264,7 @@ ACE_Stream::remove (const ACE_TCHAR *name, mod->close (flags); // Don't delete the Module unless the flags request this. - if (flags != ACE_Module::M_DELETE_NONE) + if (flags != ACE_Module::M_DELETE_NONE) { // Release the memory. delete mod; @@ -280,11 +280,11 @@ ACE_Stream::remove (const ACE_TCHAR *name, return -1; } -template ACE_Module * -ACE_Stream::find (const ACE_TCHAR *name) +template ACE_Module * +ACE_Stream::find (const ACE_TCHAR *name) { - ACE_TRACE ("ACE_Stream::find"); - for (ACE_Module *mod = this->stream_head_; + ACE_TRACE ("ACE_Stream::find"); + for (ACE_Module *mod = this->stream_head_; mod != 0; mod = mod->next ()) if (ACE_OS::strcmp (mod->name (), name) == 0) @@ -295,16 +295,16 @@ ACE_Stream::find (const ACE_TCHAR *name) // Actually push a module onto the stack... -template int -ACE_Stream::push_module (ACE_Module *new_top, - ACE_Module *current_top, - ACE_Module *head) +template int +ACE_Stream::push_module (ACE_Module *new_top, + ACE_Module *current_top, + ACE_Module *head) { - ACE_TRACE ("ACE_Stream::push_module"); - ACE_Task *nt_reader = new_top->reader (); - ACE_Task *nt_writer = new_top->writer (); - ACE_Task *ct_reader = 0; - ACE_Task *ct_writer = 0; + ACE_TRACE ("ACE_Stream::push_module"); + ACE_Task *nt_reader = new_top->reader (); + ACE_Task *nt_writer = new_top->writer (); + ACE_Task *ct_reader = 0; + ACE_Task *ct_writer = 0; if (current_top) { @@ -333,41 +333,45 @@ ACE_Stream::push_module (ACE_Module *new_top, return 0; } -template int -ACE_Stream::open (void *a, - ACE_Module *head, - ACE_Module *tail) +template int +ACE_Stream::open (void *a, + ACE_Module *head, + ACE_Module *tail) { - ACE_TRACE ("ACE_Stream::open"); + ACE_TRACE ("ACE_Stream::open"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); - ACE_Task *h1 = 0, *h2 = 0; - ACE_Task *t1 = 0, *t2 = 0; + ACE_Task *h1 = 0, *h2 = 0; + ACE_Task *t1 = 0, *t2 = 0; if (head == 0) { + typedef ACE_Stream_Head STREAM_HEAD_TYPE; ACE_NEW_NORETURN (h1, - ACE_Stream_Head); + STREAM_HEAD_TYPE); ACE_NEW_NORETURN (h2, - ACE_Stream_Head); + STREAM_HEAD_TYPE); + typedef ACE_Module MODULE_TYPE; ACE_NEW_NORETURN (head, - ACE_Module (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 STREAM_TAIL_TYPE; ACE_NEW_NORETURN (t1, - ACE_Stream_Tail); + STREAM_TAIL_TYPE); ACE_NEW_NORETURN (t2, - ACE_Stream_Tail); + STREAM_TAIL_TYPE); + typedef ACE_Module MODULE_TYPE; ACE_NEW_NORETURN (tail, - ACE_Module (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::open (void *a, return 0; } -template int -ACE_Stream::close (int flags) +template int +ACE_Stream::close (int flags) { - ACE_TRACE ("ACE_Stream::close"); + ACE_TRACE ("ACE_Stream::close"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); if (this->stream_head_ != 0 @@ -437,11 +441,11 @@ ACE_Stream::close (int flags) return 0; } -template int -ACE_Stream::control (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd, +template int +ACE_Stream::control (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd, void *a) { - ACE_TRACE ("ACE_Stream::control"); + ACE_TRACE ("ACE_Stream::control"); ACE_IO_Cntl_Msg ioc (cmd); ACE_Message_Block *db = 0; @@ -496,15 +500,15 @@ ACE_Stream::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 int -ACE_Stream::link_i (ACE_Stream &us) +template int +ACE_Stream::link_i (ACE_Stream &us) { - ACE_TRACE ("ACE_Stream::link_i"); + ACE_TRACE ("ACE_Stream::link_i"); this->linked_us_ = &us; // Make sure the other side is also linked to us! us.linked_us_ = this; - ACE_Module *my_tail = this->stream_head_; + ACE_Module *my_tail = this->stream_head_; if (my_tail == 0) return -1; @@ -513,7 +517,7 @@ ACE_Stream::link_i (ACE_Stream &us) while (my_tail->next () != this->stream_tail_) my_tail = my_tail->next (); - ACE_Module *other_tail = us.stream_head_; + ACE_Module *other_tail = us.stream_head_; if (other_tail == 0) return -1; @@ -528,10 +532,10 @@ ACE_Stream::link_i (ACE_Stream &us) return 0; } -template int -ACE_Stream::link (ACE_Stream &us) +template int +ACE_Stream::link (ACE_Stream &us) { - ACE_TRACE ("ACE_Stream::link"); + ACE_TRACE ("ACE_Stream::link"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); @@ -540,16 +544,16 @@ ACE_Stream::link (ACE_Stream &us) // Must be called with locks held... -template int -ACE_Stream::unlink_i (void) +template int +ACE_Stream::unlink_i (void) { - ACE_TRACE ("ACE_Stream::unlink_i"); + ACE_TRACE ("ACE_Stream::unlink_i"); // Only try to unlink if we are in fact still linked! if (this->linked_us_ != 0) { - ACE_Module *my_tail = this->stream_head_; + ACE_Module *my_tail = this->stream_head_; // Only relink if we still exist! if (my_tail) @@ -562,7 +566,7 @@ ACE_Stream::unlink_i (void) my_tail->writer ()->next (this->stream_tail_->writer ()); } - ACE_Module *other_tail = + ACE_Module *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::unlink_i (void) return -1; } -template int -ACE_Stream::unlink (void) +template int +ACE_Stream::unlink (void) { - ACE_TRACE ("ACE_Stream::unlink"); + ACE_TRACE ("ACE_Stream::unlink"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); return this->unlink_i (); } -template -ACE_Stream::ACE_Stream (void * a, - ACE_Module *head, - ACE_Module *tail) +template +ACE_Stream::ACE_Stream (void * a, + ACE_Module *head, + ACE_Module *tail) : stream_head_ (0), stream_tail_ (0), linked_us_ (0), - final_close_ (lock_) + final_close_ (lock_, ACE_Condition_Attributes_T ()) { - ACE_TRACE ("ACE_Stream::ACE_Stream"); + ACE_TRACE ("ACE_Stream::ACE_Stream"); if (this->open (a, head, tail) == -1) ACE_ERROR ((LM_ERROR, - ACE_TEXT ("ACE_Stream::open (%s, %s)\n"), + ACE_TEXT ("ACE_Stream::open (%s, %s)\n"), head->name (), tail->name ())); } -template -ACE_Stream::~ACE_Stream (void) +template +ACE_Stream::~ACE_Stream (void) { - ACE_TRACE ("ACE_Stream::~ACE_Stream"); + ACE_TRACE ("ACE_Stream::~ACE_Stream"); if (this->stream_head_ != 0) this->close (); } -template -ACE_Stream_Iterator::ACE_Stream_Iterator (const ACE_Stream &sr) +template +ACE_Stream_Iterator::ACE_Stream_Iterator (const ACE_Stream &sr) : next_ (sr.stream_head_) { - ACE_TRACE ("ACE_Stream_Iterator::ACE_Stream_Iterator"); + ACE_TRACE ("ACE_Stream_Iterator::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 class ACE_Stream_Iterator; +template 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 +template class ACE_Stream { public: - friend class ACE_Stream_Iterator; + friend class ACE_Stream_Iterator; enum { @@ -66,8 +66,8 @@ public: * @a arg is the value past in to the methods of the tasks. */ ACE_Stream (void *arg = 0, - ACE_Module *head = 0, - ACE_Module *tail = 0); + ACE_Module *head = 0, + ACE_Module *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 *head = 0, - ACE_Module *tail = 0); + ACE_Module *head = 0, + ACE_Module *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 *mod); + virtual int push (ACE_Module *mod); /// Remove the @a mod right below the Stream head and close it down. // The hook methods of the 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 *&mod); + virtual int top (ACE_Module *&mod); /// Insert a new module @a mod below the named module @a prev_name. virtual int insert (const ACE_TCHAR *prev_name, - ACE_Module *mod); + ACE_Module *mod); /// Replace the named module @a replace_name with a new module @a mod. virtual int replace (const ACE_TCHAR *replace_name, - ACE_Module *mod, + ACE_Module *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 *head (void); + virtual ACE_Module *head (void); /// Return current stream tail. - virtual ACE_Module *tail (void); + virtual ACE_Module *tail (void); /// Find a particular ACE_Module. - virtual ACE_Module *find (const ACE_TCHAR *mod); + virtual ACE_Module *find (const ACE_TCHAR *mod); /// Create a pipe between two Streams. - virtual int link (ACE_Stream &); + virtual int link (ACE_Stream &); /// 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 &); + int link_i (ACE_Stream &); /// Must a new module onto the Stream. - int push_module (ACE_Module *, - ACE_Module * = 0, - ACE_Module * = 0); + int push_module (ACE_Module *, + ACE_Module * = 0, + ACE_Module * = 0); /// Pointer to the head of the stream. - ACE_Module *stream_head_; + ACE_Module *stream_head_; /// Pointer to the tail of the stream. - ACE_Module *stream_tail_; + ACE_Module *stream_tail_; /// Pointer to an adjoining linked stream. - ACE_Stream *linked_us_; + ACE_Stream *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 +template class ACE_Stream_Iterator { public: // = Initialization method. - ACE_Stream_Iterator (const ACE_Stream &sr); + ACE_Stream_Iterator (const ACE_Stream &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 *&next_item); + int next (const ACE_Module *&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 *next_; + ACE_Module *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_INLINE ACE_Module * -ACE_Stream::head (void) +template ACE_INLINE ACE_Module * +ACE_Stream::head (void) { - ACE_TRACE ("ACE_Stream::head"); + ACE_TRACE ("ACE_Stream::head"); return this->stream_head_; } -template ACE_INLINE ACE_Module * -ACE_Stream::tail (void) +template ACE_INLINE ACE_Module * +ACE_Stream::tail (void) { - ACE_TRACE ("ACE_Stream::tail"); + ACE_TRACE ("ACE_Stream::tail"); return this->stream_tail_; } -template ACE_INLINE int -ACE_Stream::wait (void) +template ACE_INLINE int +ACE_Stream::wait (void) { - ACE_TRACE ("ACE_Stream::wait"); + ACE_TRACE ("ACE_Stream::wait"); return this->final_close_.wait (); } -template ACE_INLINE int -ACE_Stream_Iterator::next (const ACE_Module *&mod) +template ACE_INLINE int +ACE_Stream_Iterator::next (const ACE_Module *&mod) { - ACE_TRACE ("ACE_Stream_Iterator::next"); + ACE_TRACE ("ACE_Stream_Iterator::next"); mod = this->next_; return this->next_ != 0; } -template ACE_INLINE int -ACE_Stream_Iterator::done (void) const +template ACE_INLINE int +ACE_Stream_Iterator::done (void) const { - ACE_TRACE ("ACE_Stream_Iterator::done"); + ACE_TRACE ("ACE_Stream_Iterator::done"); return this->next_ == 0; } -template int -ACE_Stream_Iterator::advance (void) +template int +ACE_Stream_Iterator::advance (void) { - ACE_TRACE ("ACE_Stream_Iterator::advance"); + ACE_TRACE ("ACE_Stream_Iterator::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_Stream_Head::ACE_Stream_Head (void) +template +ACE_Stream_Head::ACE_Stream_Head (void) { - ACE_TRACE ("ACE_Stream_Head::ACE_Stream_Head"); + ACE_TRACE ("ACE_Stream_Head::ACE_Stream_Head"); } -template -ACE_Stream_Head::~ACE_Stream_Head (void) +template +ACE_Stream_Head::~ACE_Stream_Head (void) { - ACE_TRACE ("ACE_Stream_Head::~ACE_Stream_Head"); + ACE_TRACE ("ACE_Stream_Head::~ACE_Stream_Head"); } -template void -ACE_Stream_Head::dump (void) const +template void +ACE_Stream_Head::dump (void) const { #if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Stream_Head::dump"); + ACE_TRACE ("ACE_Stream_Head::dump"); #endif /* ACE_HAS_DUMP */ } // ACE_Module that act as the head and tail of a Stream. -template int -ACE_Stream_Head::open (void *) +template int +ACE_Stream_Head::open (void *) { - ACE_TRACE ("ACE_Stream_Head::open"); + ACE_TRACE ("ACE_Stream_Head::open"); return 0; } -template int -ACE_Stream_Head::close (u_long) +template int +ACE_Stream_Head::close (u_long) { - ACE_TRACE ("ACE_Stream_Head::close"); + ACE_TRACE ("ACE_Stream_Head::close"); return 0; } -template int -ACE_Stream_Head::svc (void) +template int +ACE_Stream_Head::svc (void) { - ACE_TRACE ("ACE_Stream_Head::svc"); + ACE_TRACE ("ACE_Stream_Head::svc"); return -1; } -template int -ACE_Stream_Head::control (ACE_Message_Block *mb) +template int +ACE_Stream_Head::control (ACE_Message_Block *mb) { - ACE_TRACE ("ACE_Stream_Head::control"); + ACE_TRACE ("ACE_Stream_Head::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::control (ACE_Message_Block *mb) // Performs canonical flushing at the ACE_Stream Head. -template int -ACE_Stream_Head::canonical_flush (ACE_Message_Block *mb) +template int +ACE_Stream_Head::canonical_flush (ACE_Message_Block *mb) { - ACE_TRACE ("ACE_Stream_Head::canonical_flush"); + ACE_TRACE ("ACE_Stream_Head::canonical_flush"); char *cp = mb->rd_ptr (); if (ACE_BIT_ENABLED (*cp, ACE_Task_Flags::ACE_FLUSHR)) @@ -99,11 +99,11 @@ ACE_Stream_Head::canonical_flush (ACE_Message_Block *mb) return 0; } -template int -ACE_Stream_Head::put (ACE_Message_Block *mb, +template int +ACE_Stream_Head::put (ACE_Message_Block *mb, ACE_Time_Value *tv) { - ACE_TRACE ("ACE_Stream_Head::put"); + ACE_TRACE ("ACE_Stream_Head::put"); int res = 0; if (mb->msg_type () == ACE_Message_Block::MB_IOCTL @@ -126,17 +126,17 @@ ACE_Stream_Head::put (ACE_Message_Block *mb, } } -template int -ACE_Stream_Head::init (int, ACE_TCHAR *[]) +template int +ACE_Stream_Head::init (int, ACE_TCHAR *[]) { - ACE_TRACE ("ACE_Stream_Head::init"); + ACE_TRACE ("ACE_Stream_Head::init"); return 0; } -template int -ACE_Stream_Head::info (ACE_TCHAR **strp, size_t length) const +template int +ACE_Stream_Head::info (ACE_TCHAR **strp, size_t length) const { - ACE_TRACE ("ACE_Stream_Head::info"); + ACE_TRACE ("ACE_Stream_Head::info"); const ACE_TCHAR *name = this->name (); if (*strp == 0 && (*strp = ACE_OS::strdup (name)) == 0) @@ -146,60 +146,60 @@ ACE_Stream_Head::info (ACE_TCHAR **strp, size_t length) const return static_cast (ACE_OS::strlen (name)); } -template int -ACE_Stream_Head::fini (void) +template int +ACE_Stream_Head::fini (void) { - ACE_TRACE ("ACE_Stream_Head::fini"); + ACE_TRACE ("ACE_Stream_Head::fini"); return 0; } ACE_ALLOC_HOOK_DEFINE(ACE_Stream_Tail) -template -ACE_Stream_Tail::ACE_Stream_Tail (void) +template +ACE_Stream_Tail::ACE_Stream_Tail (void) { - ACE_TRACE ("ACE_Stream_Tail::ACE_Stream_Tail"); + ACE_TRACE ("ACE_Stream_Tail::ACE_Stream_Tail"); } -template -ACE_Stream_Tail::~ACE_Stream_Tail (void) +template +ACE_Stream_Tail::~ACE_Stream_Tail (void) { - ACE_TRACE ("ACE_Stream_Tail::~ACE_Stream_Tail"); + ACE_TRACE ("ACE_Stream_Tail::~ACE_Stream_Tail"); } -template void -ACE_Stream_Tail::dump (void) const +template void +ACE_Stream_Tail::dump (void) const { #if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Stream_Tail::dump"); + ACE_TRACE ("ACE_Stream_Tail::dump"); #endif /* ACE_HAS_DUMP */ } -template int -ACE_Stream_Tail::open (void *) +template int +ACE_Stream_Tail::open (void *) { - ACE_TRACE ("ACE_Stream_Tail::open"); + ACE_TRACE ("ACE_Stream_Tail::open"); return 0; } -template int -ACE_Stream_Tail::close (u_long) +template int +ACE_Stream_Tail::close (u_long) { - ACE_TRACE ("ACE_Stream_Tail::close"); + ACE_TRACE ("ACE_Stream_Tail::close"); return 0; } -template int -ACE_Stream_Tail::svc (void) +template int +ACE_Stream_Tail::svc (void) { - ACE_TRACE ("ACE_Stream_Tail::svc"); + ACE_TRACE ("ACE_Stream_Tail::svc"); return -1; } -template int -ACE_Stream_Tail::control (ACE_Message_Block *mb) +template int +ACE_Stream_Tail::control (ACE_Message_Block *mb) { - ACE_TRACE ("ACE_Stream_Tail::control"); + ACE_TRACE ("ACE_Stream_Tail::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::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 int -ACE_Stream_Tail::canonical_flush (ACE_Message_Block *mb) +template int +ACE_Stream_Tail::canonical_flush (ACE_Message_Block *mb) { - ACE_TRACE ("ACE_Stream_Tail::canonical_flush"); + ACE_TRACE ("ACE_Stream_Tail::canonical_flush"); char *cp = mb->rd_ptr (); if (ACE_BIT_ENABLED (*cp, ACE_Task_Flags::ACE_FLUSHW)) @@ -246,11 +247,11 @@ ACE_Stream_Tail::canonical_flush (ACE_Message_Block *mb) return 0; } -template int -ACE_Stream_Tail::put (ACE_Message_Block *mb, +template int +ACE_Stream_Tail::put (ACE_Message_Block *mb, ACE_Time_Value *) { - ACE_TRACE ("ACE_Stream_Tail::put"); + ACE_TRACE ("ACE_Stream_Tail::put"); if (this->is_writer ()) { @@ -269,17 +270,17 @@ ACE_Stream_Tail::put (ACE_Message_Block *mb, return -1; } -template int -ACE_Stream_Tail::init (int, ACE_TCHAR *[]) +template int +ACE_Stream_Tail::init (int, ACE_TCHAR *[]) { - ACE_TRACE ("ACE_Stream_Tail::init"); + ACE_TRACE ("ACE_Stream_Tail::init"); return 0; } -template int -ACE_Stream_Tail::info (ACE_TCHAR **strp, size_t length) const +template int +ACE_Stream_Tail::info (ACE_TCHAR **strp, size_t length) const { - ACE_TRACE ("ACE_Stream_Tail::info"); + ACE_TRACE ("ACE_Stream_Tail::info"); const ACE_TCHAR *name = this->name (); if (*strp == 0 && (*strp = ACE_OS::strdup (name)) == 0) @@ -289,76 +290,76 @@ ACE_Stream_Tail::info (ACE_TCHAR **strp, size_t length) const return static_cast (ACE_OS::strlen (name)); } -template int -ACE_Stream_Tail::fini (void) +template int +ACE_Stream_Tail::fini (void) { - ACE_TRACE ("ACE_Stream_Tail::fini"); + ACE_TRACE ("ACE_Stream_Tail::fini"); return 0; } ACE_ALLOC_HOOK_DEFINE(ACE_Thru_Task) -template -ACE_Thru_Task::ACE_Thru_Task (void) +template +ACE_Thru_Task::ACE_Thru_Task (void) { - ACE_TRACE ("ACE_Thru_Task::ACE_Thru_Task"); + ACE_TRACE ("ACE_Thru_Task::ACE_Thru_Task"); } -template -ACE_Thru_Task::~ACE_Thru_Task (void) +template +ACE_Thru_Task::~ACE_Thru_Task (void) { - ACE_TRACE ("ACE_Thru_Task::~ACE_Thru_Task"); + ACE_TRACE ("ACE_Thru_Task::~ACE_Thru_Task"); } -template void -ACE_Thru_Task::dump (void) const +template void +ACE_Thru_Task::dump (void) const { #if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Thru_Task::dump"); + ACE_TRACE ("ACE_Thru_Task::dump"); #endif /* ACE_HAS_DUMP */ } -template int -ACE_Thru_Task::open (void *) +template int +ACE_Thru_Task::open (void *) { - ACE_TRACE ("ACE_Thru_Task::open"); + ACE_TRACE ("ACE_Thru_Task::open"); return 0; } -template int -ACE_Thru_Task::close (u_long) +template int +ACE_Thru_Task::close (u_long) { - ACE_TRACE ("ACE_Thru_Task::close"); + ACE_TRACE ("ACE_Thru_Task::close"); return 0; } -template int -ACE_Thru_Task::svc (void) +template int +ACE_Thru_Task::svc (void) { - ACE_TRACE ("ACE_Thru_Task::svc"); + ACE_TRACE ("ACE_Thru_Task::svc"); return -1; } -template int -ACE_Thru_Task::put (ACE_Message_Block *msg, +template int +ACE_Thru_Task::put (ACE_Message_Block *msg, ACE_Time_Value *tv) { - ACE_TRACE ("ACE_Thru_Task::put"); + ACE_TRACE ("ACE_Thru_Task::put"); return this->put_next (msg, tv); } -template int -ACE_Thru_Task::init (int, ACE_TCHAR *[]) +template int +ACE_Thru_Task::init (int, ACE_TCHAR *[]) { - ACE_TRACE ("ACE_Thru_Task::init"); + ACE_TRACE ("ACE_Thru_Task::init"); return 0; } -template int -ACE_Thru_Task::info (ACE_TCHAR **strp, +template int +ACE_Thru_Task::info (ACE_TCHAR **strp, size_t length) const { - ACE_TRACE ("ACE_Thru_Task::info"); + ACE_TRACE ("ACE_Thru_Task::info"); const ACE_TCHAR *name = this->name (); if (*strp == 0 && (*strp = ACE_OS::strdup (name)) == 0) @@ -368,10 +369,10 @@ ACE_Thru_Task::info (ACE_TCHAR **strp, return static_cast (ACE_OS::strlen (name)); } -template int -ACE_Thru_Task::fini (void) +template int +ACE_Thru_Task::fini (void) { - ACE_TRACE ("ACE_Thru_Task::fini"); + ACE_TRACE ("ACE_Thru_Task::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 -class ACE_Stream_Head : public ACE_Task +template +class ACE_Stream_Head : public ACE_Task { 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 -class ACE_Stream_Tail : public ACE_Task +template +class ACE_Stream_Tail : public ACE_Task { 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 -class ACE_Thru_Task : public ACE_Task +template +class ACE_Thru_Task : public ACE_Task { 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_Condition; +typedef ACE_Condition ACE_Null_Condition; +typedef ACE_Condition ACE_Condition_Thread_Mutex; +typedef ACE_Condition 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 void -ACE_Task_Ex::dump (void) const +template void +ACE_Task_Ex::dump (void) const { #if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Task_Ex::dump"); + ACE_TRACE ("ACE_Task_Ex::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::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_Task_Ex::ACE_Task_Ex (ACE_Thread_Manager *thr_man, - ACE_Message_Queue_Ex *mq) +template +ACE_Task_Ex::ACE_Task_Ex (ACE_Thread_Manager *thr_man, + ACE_Message_Queue_Ex *mq) : ACE_Task_Base (thr_man), msg_queue_ (0), delete_msg_queue_ (false), mod_ (0), next_ (0) { - ACE_TRACE ("ACE_Task_Ex::ACE_Task_Ex"); + ACE_TRACE ("ACE_Task_Ex::ACE_Task_Ex"); if (mq == 0) { ACE_NEW (mq, - (ACE_Message_Queue_Ex)); + (ACE_Message_Queue_Ex)); this->delete_msg_queue_ = true; } this->msg_queue_ = mq; } -template -ACE_Task_Ex::~ACE_Task_Ex (void) +template +ACE_Task_Ex::~ACE_Task_Ex (void) { - ACE_TRACE ("ACE_Task_Ex::~ACE_Task_Ex"); + ACE_TRACE ("ACE_Task_Ex::~ACE_Task_Ex"); if (this->delete_msg_queue_) delete this->msg_queue_; @@ -77,10 +77,10 @@ ACE_Task_Ex::~ACE_Task_Ex (void) this->delete_msg_queue_ = false; } -template ACE_Task * -ACE_Task_Ex::sibling (void) +template ACE_Task * +ACE_Task_Ex::sibling (void) { - ACE_TRACE ("ACE_Task_Ex::sibling"); + ACE_TRACE ("ACE_Task_Ex::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::sibling (void) */ } -template const ACE_TCHAR * -ACE_Task_Ex::name (void) const +template const ACE_TCHAR * +ACE_Task_Ex::name (void) const { - ACE_TRACE ("ACE_Task_Ex::name"); + ACE_TRACE ("ACE_Task_Ex::name"); if (this->mod_ == 0) return 0; else return this->mod_->name (); } -template ACE_Module * -ACE_Task_Ex::module (void) const +template ACE_Module * +ACE_Task_Ex::module (void) const { - ACE_TRACE ("ACE_Task_Ex::module"); + ACE_TRACE ("ACE_Task_Ex::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 class ACE_Module; +template class ACE_Module; /** * @class ACE_Task_Ex @@ -57,14 +57,14 @@ template class ACE_Module; * When User (and legacy code) write ACE_Task, specialized ACE_Task * code is in action. */ -template +template class ACE_Task_Ex : public ACE_Task_Base, private ACE_Copy_Disabled { public: - friend class ACE_Module; + friend class ACE_Module; friend class ACE_Module_Type; - typedef ACE_Message_Queue_Ex MESSAGE_QUEUE_EX; + typedef ACE_Message_Queue_Ex 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 *next (void); + ACE_Task *next (void); /// Set next Task pointer. - void next (ACE_Task *); + void next (ACE_Task *); /// Alwasy return 0. @todo FIXME - ACE_Task *sibling (void); + ACE_Task *sibling (void); /// Return the Task's Module if there is one, else returns 0. - ACE_Module *module (void) const; + ACE_Module *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 *mod_; + ACE_Module *mod_; /// Pointer to adjacent ACE_Task. - ACE_Task *next_; + ACE_Task *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_INLINE void -ACE_Task_Ex::water_marks (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd, +template ACE_INLINE void +ACE_Task_Ex::water_marks (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd, size_t wm_size) { - ACE_TRACE ("ACE_Task_Ex::water_marks"); + ACE_TRACE ("ACE_Task_Ex::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_INLINE int -ACE_Task_Ex::getq (ACE_MESSAGE_TYPE *&mb, ACE_Time_Value *tv) +template ACE_INLINE int +ACE_Task_Ex::getq (ACE_MESSAGE_TYPE *&mb, ACE_Time_Value *tv) { - ACE_TRACE ("ACE_Task_Ex::getq"); + ACE_TRACE ("ACE_Task_Ex::getq"); return this->msg_queue_->dequeue_head (mb, tv); } -template ACE_INLINE int -ACE_Task_Ex::putq (ACE_MESSAGE_TYPE *mb, ACE_Time_Value *tv) +template ACE_INLINE int +ACE_Task_Ex::putq (ACE_MESSAGE_TYPE *mb, ACE_Time_Value *tv) { - ACE_TRACE ("ACE_Task_Ex::putq"); + ACE_TRACE ("ACE_Task_Ex::putq"); return this->msg_queue_->enqueue_tail (mb, tv); } -template ACE_INLINE int -ACE_Task_Ex::ungetq (ACE_MESSAGE_TYPE *mb, ACE_Time_Value *tv) +template ACE_INLINE int +ACE_Task_Ex::ungetq (ACE_MESSAGE_TYPE *mb, ACE_Time_Value *tv) { - ACE_TRACE ("ACE_Task_Ex::ungetq"); + ACE_TRACE ("ACE_Task_Ex::ungetq"); return this->msg_queue_->enqueue_head (mb, tv); } -template ACE_INLINE int -ACE_Task_Ex::flush (u_long flag) +template ACE_INLINE int +ACE_Task_Ex::flush (u_long flag) { - ACE_TRACE ("ACE_Task_Ex::flush"); + ACE_TRACE ("ACE_Task_Ex::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_INLINE void -ACE_Task_Ex::msg_queue (ACE_Message_Queue_Ex *mq) +template ACE_INLINE void +ACE_Task_Ex::msg_queue (ACE_Message_Queue_Ex *mq) { - ACE_TRACE ("ACE_Task_Ex::msg_queue"); + ACE_TRACE ("ACE_Task_Ex::msg_queue"); if (this->delete_msg_queue_) { delete this->msg_queue_; @@ -58,44 +58,44 @@ ACE_Task_Ex::msg_queue (ACE_Message_Queue_Exmsg_queue_ = mq; } -template ACE_Message_Queue_Ex * -ACE_Task_Ex::msg_queue (void) +template ACE_Message_Queue_Ex * +ACE_Task_Ex::msg_queue (void) { - ACE_TRACE ("ACE_Task_Ex::msg_queue"); + ACE_TRACE ("ACE_Task_Ex::msg_queue"); return this->msg_queue_; } -template ACE_INLINE int -ACE_Task_Ex::reply (ACE_MESSAGE_TYPE *mb, ACE_Time_Value *tv) +template ACE_INLINE int +ACE_Task_Ex::reply (ACE_MESSAGE_TYPE *mb, ACE_Time_Value *tv) { - ACE_TRACE ("ACE_Task_Ex::reply"); + ACE_TRACE ("ACE_Task_Ex::reply"); ACE_UNUSED_ARG (mb); ACE_UNUSED_ARG (tv); return -1 ; // this->sibling ()->put_next (mb, tv); } -template ACE_INLINE ACE_Task * -ACE_Task_Ex::next (void) +template ACE_INLINE ACE_Task * +ACE_Task_Ex::next (void) { - ACE_TRACE ("ACE_Task_Ex::next"); + ACE_TRACE ("ACE_Task_Ex::next"); return this->next_; } -template ACE_INLINE void -ACE_Task_Ex::next (ACE_Task *q) +template ACE_INLINE void +ACE_Task_Ex::next (ACE_Task *q) { - ACE_TRACE ("ACE_Task_Ex::next"); + ACE_TRACE ("ACE_Task_Ex::next"); this->next_ = q; } // Transfer msg to the next ACE_Task_Ex. -template ACE_INLINE int -ACE_Task_Ex::put_next ( +template ACE_INLINE int +ACE_Task_Ex::put_next ( ACE_MESSAGE_TYPE * /* msg */, ACE_Time_Value * /* tv */) { - ACE_TRACE ("ACE_Task_Ex::put_next"); + ACE_TRACE ("ACE_Task_Ex::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 void -ACE_Task::dump (void) const +template void +ACE_Task::dump (void) const { #if defined (ACE_HAS_DUMP) - ACE_TRACE ("ACE_Task::dump"); + ACE_TRACE ("ACE_Task::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::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_Task::ACE_Task (ACE_Thread_Manager *thr_man, - ACE_Message_Queue *mq) +template +ACE_Task::ACE_Task (ACE_Thread_Manager *thr_man, + ACE_Message_Queue *mq) : ACE_Task_Base (thr_man), msg_queue_ (0), delete_msg_queue_ (false), mod_ (0), next_ (0) { - ACE_TRACE ("ACE_Task::ACE_Task"); + ACE_TRACE ("ACE_Task::ACE_Task"); if (mq == 0) { + typedef ACE_Message_Queue QUEUE_TYPE; ACE_NEW (mq, - ACE_Message_Queue); + QUEUE_TYPE); this->delete_msg_queue_ = true; } this->msg_queue_ = mq; } -template -ACE_Task::~ACE_Task (void) +template +ACE_Task::~ACE_Task (void) { - ACE_TRACE ("ACE_Task::~ACE_Task"); + ACE_TRACE ("ACE_Task::~ACE_Task"); if (this->delete_msg_queue_) delete this->msg_queue_; @@ -76,30 +77,30 @@ ACE_Task::~ACE_Task (void) this->delete_msg_queue_ = false; } -template ACE_Task * -ACE_Task::sibling (void) +template ACE_Task * +ACE_Task::sibling (void) { - ACE_TRACE ("ACE_Task::sibling"); + ACE_TRACE ("ACE_Task::sibling"); if (this->mod_ == 0) return 0; else return this->mod_->sibling (this); } -template const ACE_TCHAR * -ACE_Task::name (void) const +template const ACE_TCHAR * +ACE_Task::name (void) const { - ACE_TRACE ("ACE_Task::name"); + ACE_TRACE ("ACE_Task::name"); if (this->mod_ == 0) return 0; else return this->mod_->name (); } -template ACE_Module * -ACE_Task::module (void) const +template ACE_Module * +ACE_Task::module (void) const { - ACE_TRACE ("ACE_Task::module"); + ACE_TRACE ("ACE_Task::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 class ACE_Module; +template class ACE_Module; /** * @class ACE_Task @@ -38,11 +38,11 @@ template class ACE_Module; * This class serves as the basis for passive and active objects * in ACE. */ -template +template class ACE_Task : public ACE_Task_Base { public: - friend class ACE_Module; + friend class ACE_Module; 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 *mq = 0); + ACE_Message_Queue *mq = 0); /// Destructor. virtual ~ACE_Task (void); /// Gets the message queue associated with this task. - ACE_Message_Queue *msg_queue (void); + ACE_Message_Queue *msg_queue (void); /// Sets the message queue associated with this task. - void msg_queue (ACE_Message_Queue *); + void msg_queue (ACE_Message_Queue *); + + /// 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 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 *next (void); + ACE_Task *next (void); /// Set next Task pointer. - void next (ACE_Task *); + void next (ACE_Task *); /// Return the Task's sibling if there's one associated with the /// Task's Module, else returns 0. - ACE_Task *sibling (void); + ACE_Task *sibling (void); /// Return the Task's Module if there is one, else returns 0. - ACE_Module *module (void) const; + ACE_Module *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 *msg_queue_; + ACE_Message_Queue *msg_queue_; /// true if should delete Message_Queue, false otherwise. bool delete_msg_queue_; /// Back-pointer to the enclosing module. - ACE_Module *mod_; + ACE_Module *mod_; /// Pointer to adjacent ACE_Task. - ACE_Task *next_; + ACE_Task *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_UNIMPLEMENTED_FUNC (ACE_Task (const ACE_Task &)) + ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Task &)) + ACE_UNIMPLEMENTED_FUNC (ACE_Task (const ACE_Task &)) }; #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_INLINE void -ACE_Task::water_marks (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd, +template ACE_INLINE void +ACE_Task::water_marks (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd, size_t wm_size) { - ACE_TRACE ("ACE_Task::water_marks"); + ACE_TRACE ("ACE_Task::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_INLINE int -ACE_Task::getq (ACE_Message_Block *&mb, ACE_Time_Value *tv) +template ACE_INLINE int +ACE_Task::getq (ACE_Message_Block *&mb, ACE_Time_Value *tv) { - ACE_TRACE ("ACE_Task::getq"); + ACE_TRACE ("ACE_Task::getq"); return this->msg_queue_->dequeue_head (mb, tv); } -template ACE_INLINE int -ACE_Task::putq (ACE_Message_Block *mb, ACE_Time_Value *tv) +template ACE_INLINE int +ACE_Task::putq (ACE_Message_Block *mb, ACE_Time_Value *tv) { - ACE_TRACE ("ACE_Task::putq"); + ACE_TRACE ("ACE_Task::putq"); return this->msg_queue_->enqueue_tail (mb, tv); } -template ACE_INLINE int -ACE_Task::ungetq (ACE_Message_Block *mb, ACE_Time_Value *tv) +template ACE_INLINE int +ACE_Task::ungetq (ACE_Message_Block *mb, ACE_Time_Value *tv) { - ACE_TRACE ("ACE_Task::ungetq"); + ACE_TRACE ("ACE_Task::ungetq"); return this->msg_queue_->enqueue_head (mb, tv); } -template ACE_INLINE int -ACE_Task::flush (u_long flag) +template ACE_INLINE int +ACE_Task::flush (u_long flag) { - ACE_TRACE ("ACE_Task::flush"); + ACE_TRACE ("ACE_Task::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_INLINE void -ACE_Task::msg_queue (ACE_Message_Queue *mq) +template ACE_INLINE void +ACE_Task::msg_queue (ACE_Message_Queue *mq) { - ACE_TRACE ("ACE_Task::msg_queue"); + ACE_TRACE ("ACE_Task::msg_queue"); if (this->delete_msg_queue_) { delete this->msg_queue_; @@ -58,40 +58,58 @@ ACE_Task::msg_queue (ACE_Message_Queue *mq) this->msg_queue_ = mq; } -template ACE_Message_Queue * -ACE_Task::msg_queue (void) +template ACE_Message_Queue * +ACE_Task::msg_queue (void) { - ACE_TRACE ("ACE_Task::msg_queue"); + ACE_TRACE ("ACE_Task::msg_queue"); return this->msg_queue_; } -template ACE_INLINE int -ACE_Task::reply (ACE_Message_Block *mb, ACE_Time_Value *tv) +template +ACE_Time_Value_T +ACE_Task::gettimeofday (void) const { - ACE_TRACE ("ACE_Task::reply"); + if (this->msg_queue_ != 0) + return this->msg_queue_->gettimeofday (); + + return ACE_Time_Value_T (ACE_Time_Value::zero); +} + +template +void +ACE_Task::set_time_policy (TIME_POLICY const & rhs) +{ + if (this->msg_queue_ != 0) + this->msg_queue_->set_time_policy (rhs); +} + +template ACE_INLINE int +ACE_Task::reply (ACE_Message_Block *mb, ACE_Time_Value *tv) +{ + ACE_TRACE ("ACE_Task::reply"); return this->sibling ()->put_next (mb, tv); } -template ACE_INLINE ACE_Task * -ACE_Task::next (void) +template ACE_INLINE ACE_Task * +ACE_Task::next (void) { - ACE_TRACE ("ACE_Task::next"); + ACE_TRACE ("ACE_Task::next"); return this->next_; } -template ACE_INLINE void -ACE_Task::next (ACE_Task *q) +template ACE_INLINE void +ACE_Task::next (ACE_Task *q) { - ACE_TRACE ("ACE_Task::next"); + ACE_TRACE ("ACE_Task::next"); this->next_ = q; } // Transfer msg to the next ACE_Task. -template ACE_INLINE int -ACE_Task::put_next (ACE_Message_Block *msg, ACE_Time_Value *tv) +template ACE_INLINE int +ACE_Task::put_next (ACE_Message_Block *msg, ACE_Time_Value *tv) { - ACE_TRACE ("ACE_Task::put_next"); + ACE_TRACE ("ACE_Task::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 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 gettimeofday () const; +}; + +ACE_Time_Value_T NULL_Time_Policy::gettimeofday () const { - return ACE_Time_Value::zero; + return ACE_Time_Value_T (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 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 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 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 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 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 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; +template class ACE_Export ACE_Time_Value_T; +template class ACE_Export ACE_Time_Value_T; +template class ACE_Export ACE_Time_Value_T; +#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::operator()() const { - return ACE_OS::gettimeofday(); + return ACE_Time_Value_T (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::operator()() const { - return ACE_High_Res_Timer::gettimeofday_hr (); + return ACE_Time_Value_T (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::operator()() const { - return (*this->function_)(); + return ACE_Time_Value_T ((*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_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::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 ACE_INLINE +template ACE_Time_Policy_T::~ACE_Time_Policy_T () { } -template ACE_INLINE ACE_Time_Value +template ACE_Time_Value_T ACE_Time_Policy_T::gettimeofday () const { - return this->time_policy_ (); + return ACE_Time_Value_T (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 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 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 ACE_INLINE +template +ACE_INLINE ACE_Time_Policy_T::ACE_Time_Policy_T (TIME_POLICY const & time_policy) : time_policy_ (time_policy) { } -template ACE_INLINE ACE_Time_Value +template +ACE_INLINE ACE_Time_Value_T ACE_Time_Policy_T::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 @@ -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 +ACE_Time_Value +ACE_Time_Value_T::now () const +{ + return this->time_policy_ (); +} + +template +ACE_Time_Value +ACE_Time_Value_T::to_relative_time () const +{ + return (*this) - this->time_policy_ (); +} + +template +ACE_Time_Value +ACE_Time_Value_T::to_absolute_time () const +{ + return (*this) + this->time_policy_ (); +} + +template +ACE_Time_Value * +ACE_Time_Value_T::duplicate () const +{ + ACE_Time_Value_T * tmp = 0; + ACE_NEW_RETURN (tmp, ACE_Time_Value_T (*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 + */ +//============================================================================= + +#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