diff options
author | bala <balanatarajan@users.noreply.github.com> | 2001-12-18 20:49:32 +0000 |
---|---|---|
committer | bala <balanatarajan@users.noreply.github.com> | 2001-12-18 20:49:32 +0000 |
commit | b93c0151e05670eed53437ddf3eb483de71aacbc (patch) | |
tree | bb72168313b649aa60baf9e480ac9f5be3f1b40c | |
parent | 7ef09d323f2de715aacb8fc56854efa41b746282 (diff) | |
download | ATCD-b93c0151e05670eed53437ddf3eb483de71aacbc.tar.gz |
ChangeLogTag: Tue Dec 18 14:45:34 2001 Balachandran Natarajan <bala@cs.wustl.edu>
-rw-r--r-- | ChangeLog_Reactor_Rewrite | 16 | ||||
-rw-r--r-- | ace/Atomic_Op.cpp | 56 | ||||
-rw-r--r-- | ace/Atomic_Op.h | 165 | ||||
-rw-r--r-- | ace/Functor.h | 78 | ||||
-rw-r--r-- | ace/Functor.i | 38 | ||||
-rw-r--r-- | ace/RMCast/RMCast_Reassembly.cpp | 1 | ||||
-rw-r--r-- | ace/Synch_T.cpp | 29 | ||||
-rw-r--r-- | ace/Synch_T.h | 124 | ||||
-rw-r--r-- | protocols/ace/RMCast/RMCast_Reassembly.cpp | 1 |
9 files changed, 351 insertions, 157 deletions
diff --git a/ChangeLog_Reactor_Rewrite b/ChangeLog_Reactor_Rewrite index cae4353dc5a..5f32e80f98b 100644 --- a/ChangeLog_Reactor_Rewrite +++ b/ChangeLog_Reactor_Rewrite @@ -1,3 +1,19 @@ +Tue Dec 18 14:45:34 2001 Balachandran Natarajan <bala@cs.wustl.edu> + + * ace/Synch_T.cpp: + * ace/Synch_T.h: Removed ACE_Atomic_Op to a new file. + + * ace/Atomic_Op.h: + * ace/Atomic_Op.i: + * ace/Atomic_Op.cpp: The class ACE_Atomic_Op is in this file now. + + * ace/Functor.h: + * ace/Functor.i: Added template specializations for some base + types like ACE_UINT16. + + * ace/RMCast/RMCast_Reassembly.cpp: Removed a template + instantation for ACE_Equal_To. + Sat Dec 15 11:17:35 2001 Balachandran Natarajan <bala@cs.wustl.edu> * bin/dep.pl: Script to generate dependecies. To be run as "dep.pl diff --git a/ace/Atomic_Op.cpp b/ace/Atomic_Op.cpp new file mode 100644 index 00000000000..8bbe979d67c --- /dev/null +++ b/ace/Atomic_Op.cpp @@ -0,0 +1,56 @@ +#ifndef ACE_ATOMIC_OP_C +#define ACE_ATOMIC_OP_C + +#include "ace/Atomic_Op.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if !defined (__ACE_INLINE__) +// On non-Win32 platforms, this code will be treated as normal code. +#if !defined (ACE_WIN32) +#include "ace/Atomic_Op.i" +#endif /* !ACE_WIN32 */ + +ACE_RCSID(ace, Atomic_Op, "$Id$") + + + +#endif /* __ACE_INLINE__ */ + +ACE_ALLOC_HOOK_DEFINE(ACE_Atomic_Op) + +template <class ACE_LOCK, class TYPE> ACE_LOCK & +ACE_Atomic_Op<ACE_LOCK, TYPE>::mutex (void) +{ +// ACE_TRACE ("ACE_Atomic_Op<ACE_LOCK, TYPE>::mutex"); + return this->mutex_; +} + +template <class ACE_LOCK, class TYPE> void +ACE_Atomic_Op<ACE_LOCK, TYPE>::dump (void) const +{ +// ACE_TRACE ("ACE_Atomic_Op<ACE_LOCK, TYPE>::dump"); + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + this->mutex_.dump (); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +} + +template <class ACE_LOCK, class TYPE> +ACE_Atomic_Op<ACE_LOCK, TYPE>::ACE_Atomic_Op (void) + : value_ (0) +{ +// ACE_TRACE ("ACE_Atomic_Op<ACE_LOCK, TYPE>::ACE_Atomic_Op"); +} + +template <class ACE_LOCK, class TYPE> +ACE_Atomic_Op<ACE_LOCK, TYPE>::ACE_Atomic_Op (const TYPE &c) + : value_ (c) +{ +// ACE_TRACE ("ACE_Atomic_Op<ACE_LOCK, TYPE>::ACE_Atomic_Op"); +} + + +#endif /*ACE_ATOMIC_OP */ diff --git a/ace/Atomic_Op.h b/ace/Atomic_Op.h new file mode 100644 index 00000000000..c59a7d0ceae --- /dev/null +++ b/ace/Atomic_Op.h @@ -0,0 +1,165 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Atomic_Op.h + * + * $Id$ + * + * @author Douglas C. Schmidt <schmidt@uci.edu> + */ +//============================================================================= + +#ifndef ACE_ATOMIC_OP_H +#define ACE_ATOMIC_OP_H +#include "ace/pre.h" + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + + +/** + * @class ACE_Atomic_Op + * + * @brief Transparently parameterizes synchronization into basic + * arithmetic operations. + * + * This class is described in an article in the July/August 1994 + * issue of the C++ Report magazine. It implements a + * templatized version of the Decorator pattern from the GoF book. + */ +template <class ACE_LOCK, class TYPE> +class ACE_Atomic_Op +{ +public: + // = Initialization methods. + + /// Initialize <value_> to 0. + ACE_Atomic_Op (void); + + /// Initialize <value_> to c. + ACE_Atomic_Op (const TYPE &c); + + // = Accessors. + + /// Atomically pre-increment <value_>. + TYPE operator++ (void); + + /// Atomically post-increment <value_>. + TYPE operator++ (int); + + /// Atomically increment <value_> by i. + TYPE operator+= (const TYPE &i); + + /// Atomically pre-decrement <value_>. + TYPE operator-- (void); + + /// Atomically post-decrement <value_>. + TYPE operator-- (int); + + /// Atomically decrement <value_> by i. + TYPE operator-= (const TYPE &i); + + /// Atomically compare <value_> with i. + int operator== (const TYPE &i) const; + + /// Atomically compare <value_> with i. + int operator!= (const TYPE &i) const; + + /// Atomically check if <value_> greater than or equal to i. + int operator>= (const TYPE &i) const; + + /// Atomically check if <value_> greater than i. + int operator> (const TYPE &rhs) const; + + /// Atomically check if <value_> less than or equal to i. + int operator<= (const TYPE &rhs) const; + + /// Atomically check if <value_> less than i. + int operator< (const TYPE &rhs) const; + + /// Atomically assign i to <value_>. + void operator= (const TYPE &i); + + /// Atomically assign <rhs> to <value_>. + void operator= (const ACE_Atomic_Op<ACE_LOCK, TYPE> &rhs); + + /// Explicitly return <value_>. + TYPE value (void) const; + + /// Dump the state of an object. + void dump (void) const; + + // ACE_ALLOC_HOOK_DECLARE; + // Declare the dynamic allocation hooks. + + /// Manage copying... + ACE_Atomic_Op (const ACE_Atomic_Op<ACE_LOCK, TYPE> &); + + /** + * Returns a reference to the underlying <ACE_LOCK>. This makes it + * possible to acquire the lock explicitly, which can be useful in + * some cases if you instantiate the <ACE_Atomic_Op> with an + * <ACE_Recursive_Mutex> or <ACE_Process_Mutex>. NOTE: the right + * name would be lock_, but HP/C++ will choke on that! + */ + ACE_LOCK &mutex (void); + + /** + * Explicitly return <value_> (by reference). This gives the user + * full, unrestricted access to the underlying value. This method + * will usually be used in conjunction with explicit access to the + * lock. Use with care ;-) + */ + TYPE &value_i (void); + +private: + /// Type of synchronization mechanism. + ACE_LOCK mutex_; + + /// Current object decorated by the atomic op. + TYPE value_; +}; + + +#if defined (__ACE_INLINE__) +// On non-Win32 platforms, this code will be inlined +#if !defined (ACE_WIN32) +#include "ace/Atomic_Op.i" +#endif /* !ACE_WIN32 */ +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) + +#include "Atomic_Op.cpp" +// On Win32 platforms, this code will be included as template source +// code and will not be inlined. Therefore, we first turn off +// ACE_INLINE, set it to be nothing, include the code, and then turn +// ACE_INLINE back to its original setting. All this nonsense is +// necessary, since the generic template code that needs to be +// specialized cannot be inlined, else the compiler will ignore the +// specialization code. Also, the specialization code *must* be +// inlined or the compiler will ignore the specializations. +#if defined (ACE_WIN32) +#undef ACE_INLINE +#define ACE_INLINE +#include "ace/Atomic_Op.i" +#undef ACE_INLINE +#if defined (__ACE_INLINE__) +#define ACE_INLINE inline +#else +#define ACE_INLINE +#endif /* __ACE_INLINE__ */ +#endif /* ACE_WIN32 */ +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Atomic_Op.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include "ace/post.h" +#endif /*ACE_ATOMIC_OP_H*/ diff --git a/ace/Functor.h b/ace/Functor.h index 7eb6333016e..5e96d5cbad5 100644 --- a/ace/Functor.h +++ b/ace/Functor.h @@ -23,7 +23,7 @@ * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> * @author Sergio Flores-Gaitan <sergio@cs.wustl.edu> * @author and on STL-style functor implementations originally done by - * @author Irfan Pyarali <irfan@cs.wustl.edu> + * @author Irfan Pyarali <irfan@cs.wustl.edu> */ //============================================================================= @@ -246,6 +246,82 @@ public: const ACE_TCHAR *rhs) const; }; + ACE_TEMPLATE_SPECIALIZATION + /** + * @class ACE_Equal_To<ACE_UINT16> + * + * @brief Function object for determining whether two unsigned + * 16 bit ints are equal. + */ +class ACE_Export ACE_Equal_To<ACE_UINT16> +{ +public: + /// Simply calls built-in operators + int operator () (const ACE_UINT16 lhs, + const ACE_UINT16 rhs) const; +}; + +ACE_TEMPLATE_SPECIALIZATION +/** + * @class ACE_Equal_To<ACE_INT16> + * + * @brief Function object for determining whether two + * 16 bit ints are equal. + */ +class ACE_Export ACE_Equal_To<ACE_INT16> +{ +public: + /// Simply calls built-in operators + int operator () (const ACE_INT16 lhs, + const ACE_INT16 rhs) const; +}; + +ACE_TEMPLATE_SPECIALIZATION +/** + * @class ACE_Equal_To<ACE_UINT32> + * + * @brief Function object for determining whether two unsigned + * 32 bit ints are equal. + */ +class ACE_Export ACE_Equal_To<ACE_UINT32> +{ +public: + /// Simply calls built-in operators + int operator () (const ACE_UINT32 lhs, + const ACE_UINT32 rhs) const; +}; + +ACE_TEMPLATE_SPECIALIZATION +/** + * @class ACE_Equal_To<ACE_INT32> + * + * @brief Function object for determining whether two + * 32 bit ints are equal. + */ +class ACE_Export ACE_Equal_To<ACE_INT32> +{ +public: + /// Simply calls built-in operators + int operator () (const ACE_INT32 lhs, + const ACE_INT32 rhs) const; +}; + +ACE_TEMPLATE_SPECIALIZATION +/** + * @class ACE_Equal_To<ACE_UINT64> + * + * @brief Function object for determining whether two unsigned + * 64 bit ints are equal. + */ +class ACE_Export ACE_Equal_To<ACE_UINT64> +{ +public: + /// Simply calls built-in operators + int operator () (const ACE_UINT64 lhs, + const ACE_UINT64 rhs) const; +}; + + ACE_TEMPLATE_SPECIALIZATION /** * @class ACE_Less_Than<const diff --git a/ace/Functor.i b/ace/Functor.i index 3fe587c8b95..5e46485304d 100644 --- a/ace/Functor.i +++ b/ace/Functor.i @@ -52,7 +52,7 @@ ACE_Command_Base::~ACE_Command_Base (void) //////////////////////////////////////////////////////////// ACE_TEMPLATE_METHOD_SPECIALIZATION -ACE_INLINE +ACE_INLINE u_long ACE_Hash<char>::operator () (char t) const { @@ -123,6 +123,7 @@ ACE_Hash<ACE_TCHAR *>::operator () (const ACE_TCHAR *t) const return ACE::hash_pjw (t); } +/***********************************************************************/ ACE_TEMPLATE_METHOD_SPECIALIZATION ACE_INLINE int ACE_Equal_To<const ACE_TCHAR *>::operator () (const ACE_TCHAR *lhs, const ACE_TCHAR *rhs) const @@ -137,6 +138,41 @@ ACE_Equal_To<ACE_TCHAR *>::operator () (const ACE_TCHAR *lhs, const ACE_TCHAR *r return !ACE_OS::strcmp (lhs, rhs); } +ACE_INLINE int +ACE_Equal_To<ACE_UINT16>::operator () (const ACE_UINT16 lhs, const ACE_UINT16 rhs) const +{ + return (lhs == rhs); +} + +ACE_TEMPLATE_METHOD_SPECIALIZATION +ACE_INLINE int +ACE_Equal_To<ACE_INT16>::operator () (const ACE_INT16 lhs, const ACE_INT16 rhs) const +{ + return (lhs == rhs); +} + +ACE_TEMPLATE_METHOD_SPECIALIZATION +ACE_INLINE int +ACE_Equal_To<ACE_UINT32>::operator () (const ACE_UINT32 lhs, const ACE_UINT32 rhs) const +{ + return (lhs == rhs); +} + +ACE_TEMPLATE_METHOD_SPECIALIZATION +ACE_INLINE int +ACE_Equal_To<ACE_INT32>::operator () (const ACE_INT32 lhs, const ACE_INT32 rhs) const +{ + return (lhs == rhs); +} + +ACE_TEMPLATE_METHOD_SPECIALIZATION +ACE_INLINE int +ACE_Equal_To<ACE_UINT64>::operator () (const ACE_UINT64 lhs, const ACE_UINT64 rhs) const +{ + return (lhs == rhs); +} + +/****************************************************************************/ ACE_TEMPLATE_METHOD_SPECIALIZATION ACE_INLINE int ACE_Less_Than<const ACE_TCHAR *>::operator () (const ACE_TCHAR *lhs, const ACE_TCHAR *rhs) const diff --git a/ace/RMCast/RMCast_Reassembly.cpp b/ace/RMCast/RMCast_Reassembly.cpp index 85db12f1cf3..d20b72d88c5 100644 --- a/ace/RMCast/RMCast_Reassembly.cpp +++ b/ace/RMCast/RMCast_Reassembly.cpp @@ -135,7 +135,6 @@ template class ACE_Hash_Map_Reverse_Iterator_Ex<ACE_UINT32,ACE_RMCast_Partial_Me template class ACE_Hash_Map_Iterator_Base_Ex<ACE_UINT32,ACE_RMCast_Partial_Message*,ACE_Hash<ACE_UINT32>,ACE_Equal_To<ACE_UINT32>,ACE_Null_Mutex >; template class ACE_Hash_Map_Entry<ACE_UINT32,ACE_RMCast_Partial_Message*>; -template class ACE_Equal_To<ACE_UINT32>; template class ACE_Less_Than<ACE_UINT32>; #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/ace/Synch_T.cpp b/ace/Synch_T.cpp index 1abcca4a6db..1862faa8214 100644 --- a/ace/Synch_T.cpp +++ b/ace/Synch_T.cpp @@ -40,36 +40,7 @@ ACE_Reverse_Lock<ACE_LOCKING_MECHANISM>::~ACE_Reverse_Lock (void) { } -template <class ACE_LOCK, class TYPE> ACE_LOCK & -ACE_Atomic_Op<ACE_LOCK, TYPE>::mutex (void) -{ -// ACE_TRACE ("ACE_Atomic_Op<ACE_LOCK, TYPE>::mutex"); - return this->mutex_; -} - -template <class ACE_LOCK, class TYPE> void -ACE_Atomic_Op<ACE_LOCK, TYPE>::dump (void) const -{ -// ACE_TRACE ("ACE_Atomic_Op<ACE_LOCK, TYPE>::dump"); - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - this->mutex_.dump (); - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -} - -template <class ACE_LOCK, class TYPE> -ACE_Atomic_Op<ACE_LOCK, TYPE>::ACE_Atomic_Op (void) - : value_ (0) -{ -// ACE_TRACE ("ACE_Atomic_Op<ACE_LOCK, TYPE>::ACE_Atomic_Op"); -} - -template <class ACE_LOCK, class TYPE> -ACE_Atomic_Op<ACE_LOCK, TYPE>::ACE_Atomic_Op (const TYPE &c) - : value_ (c) -{ -// ACE_TRACE ("ACE_Atomic_Op<ACE_LOCK, TYPE>::ACE_Atomic_Op"); -} // **************************************************************** // ACE_ALLOC_HOOK_DEFINE(ACE_Guard) diff --git a/ace/Synch_T.h b/ace/Synch_T.h index b26bb7cd60e..83906e79094 100644 --- a/ace/Synch_T.h +++ b/ace/Synch_T.h @@ -201,108 +201,7 @@ private: ACE_Acquire_Method::METHOD_TYPE acquire_method_; }; -/** - * @class ACE_Atomic_Op - * - * @brief Transparently parameterizes synchronization into basic - * arithmetic operations. - * - * This class is described in an article in the July/August 1994 - * issue of the C++ Report magazine. It implements a - * templatized version of the Decorator pattern from the GoF book. - */ -template <class ACE_LOCK, class TYPE> -class ACE_Atomic_Op -{ -public: - // = Initialization methods. - - /// Initialize <value_> to 0. - ACE_Atomic_Op (void); - - /// Initialize <value_> to c. - ACE_Atomic_Op (const TYPE &c); - - // = Accessors. - - /// Atomically pre-increment <value_>. - TYPE operator++ (void); - - /// Atomically post-increment <value_>. - TYPE operator++ (int); - - /// Atomically increment <value_> by i. - TYPE operator+= (const TYPE &i); - - /// Atomically pre-decrement <value_>. - TYPE operator-- (void); - - /// Atomically post-decrement <value_>. - TYPE operator-- (int); - - /// Atomically decrement <value_> by i. - TYPE operator-= (const TYPE &i); - - /// Atomically compare <value_> with i. - int operator== (const TYPE &i) const; - - /// Atomically compare <value_> with i. - int operator!= (const TYPE &i) const; - - /// Atomically check if <value_> greater than or equal to i. - int operator>= (const TYPE &i) const; - - /// Atomically check if <value_> greater than i. - int operator> (const TYPE &rhs) const; - - /// Atomically check if <value_> less than or equal to i. - int operator<= (const TYPE &rhs) const; - - /// Atomically check if <value_> less than i. - int operator< (const TYPE &rhs) const; - /// Atomically assign i to <value_>. - void operator= (const TYPE &i); - - /// Atomically assign <rhs> to <value_>. - void operator= (const ACE_Atomic_Op<ACE_LOCK, TYPE> &rhs); - - /// Explicitly return <value_>. - TYPE value (void) const; - - /// Dump the state of an object. - void dump (void) const; - - // ACE_ALLOC_HOOK_DECLARE; - // Declare the dynamic allocation hooks. - - /// Manage copying... - ACE_Atomic_Op (const ACE_Atomic_Op<ACE_LOCK, TYPE> &); - - /** - * Returns a reference to the underlying <ACE_LOCK>. This makes it - * possible to acquire the lock explicitly, which can be useful in - * some cases if you instantiate the <ACE_Atomic_Op> with an - * <ACE_Recursive_Mutex> or <ACE_Process_Mutex>. NOTE: the right - * name would be lock_, but HP/C++ will choke on that! - */ - ACE_LOCK &mutex (void); - - /** - * Explicitly return <value_> (by reference). This gives the user - * full, unrestricted access to the underlying value. This method - * will usually be used in conjunction with explicit access to the - * lock. Use with care ;-) - */ - TYPE &value_i (void); - -private: - /// Type of synchronization mechanism. - ACE_LOCK mutex_; - - /// Current object decorated by the atomic op. - TYPE value_; -}; /** * @class ACE_TSS @@ -992,33 +891,10 @@ public: #if defined (__ACE_INLINE__) #include "ace/Synch_T.i" -// On non-Win32 platforms, this code will be inlined -#if !defined (ACE_WIN32) -#include "ace/Atomic_Op.i" -#endif /* !ACE_WIN32 */ #endif /* __ACE_INLINE__ */ #if defined (ACE_TEMPLATES_REQUIRE_SOURCE) #include "ace/Synch_T.cpp" -// On Win32 platforms, this code will be included as template source -// code and will not be inlined. Therefore, we first turn off -// ACE_INLINE, set it to be nothing, include the code, and then turn -// ACE_INLINE back to its original setting. All this nonsense is -// necessary, since the generic template code that needs to be -// specialized cannot be inlined, else the compiler will ignore the -// specialization code. Also, the specialization code *must* be -// inlined or the compiler will ignore the specializations. -#if defined (ACE_WIN32) -#undef ACE_INLINE -#define ACE_INLINE -#include "ace/Atomic_Op.i" -#undef ACE_INLINE -#if defined (__ACE_INLINE__) -#define ACE_INLINE inline -#else -#define ACE_INLINE -#endif /* __ACE_INLINE__ */ -#endif /* ACE_WIN32 */ #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) diff --git a/protocols/ace/RMCast/RMCast_Reassembly.cpp b/protocols/ace/RMCast/RMCast_Reassembly.cpp index 85db12f1cf3..d20b72d88c5 100644 --- a/protocols/ace/RMCast/RMCast_Reassembly.cpp +++ b/protocols/ace/RMCast/RMCast_Reassembly.cpp @@ -135,7 +135,6 @@ template class ACE_Hash_Map_Reverse_Iterator_Ex<ACE_UINT32,ACE_RMCast_Partial_Me template class ACE_Hash_Map_Iterator_Base_Ex<ACE_UINT32,ACE_RMCast_Partial_Message*,ACE_Hash<ACE_UINT32>,ACE_Equal_To<ACE_UINT32>,ACE_Null_Mutex >; template class ACE_Hash_Map_Entry<ACE_UINT32,ACE_RMCast_Partial_Message*>; -template class ACE_Equal_To<ACE_UINT32>; template class ACE_Less_Than<ACE_UINT32>; #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ |