summaryrefslogtreecommitdiff
path: root/ACE/ace
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>2011-12-05 20:25:15 +0000
committerSteve Huston <shuston@riverace.com>2011-12-05 20:25:15 +0000
commit9ba7a2d405767e63938d8da960510c9582695b40 (patch)
tree4e2f518517d0911d1c8eb2c76c81d8b1f3bbc26f /ACE/ace
parent9dd934d39bfd9e6449f86437e001e7ee8d8410a2 (diff)
downloadATCD-9ba7a2d405767e63938d8da960510c9582695b40.tar.gz
ChangeLogtag:Mon Dec 5 20;16:51 UTC 2011 Steve Huston <shuston@riverace.com>
Diffstat (limited to 'ACE/ace')
-rw-r--r--ACE/ace/Atomic_Op.h6
-rw-r--r--ACE/ace/Atomic_Op.inl32
-rw-r--r--ACE/ace/Atomic_Op_GCC_T.h3
-rw-r--r--ACE/ace/Atomic_Op_GCC_T.inl7
-rw-r--r--ACE/ace/Atomic_Op_T.h6
-rw-r--r--ACE/ace/Atomic_Op_T.inl17
6 files changed, 71 insertions, 0 deletions
diff --git a/ACE/ace/Atomic_Op.h b/ACE/ace/Atomic_Op.h
index 69eb3e42f70..597c218b77a 100644
--- a/ACE/ace/Atomic_Op.h
+++ b/ACE/ace/Atomic_Op.h
@@ -124,6 +124,9 @@ public:
/// Atomically assign <rhs> to @c value_.
ACE_Atomic_Op<ACE_Thread_Mutex, long> &operator= (const ACE_Atomic_Op<ACE_Thread_Mutex, long> &rhs);
+ /// Exchange value with @a newval.
+ long exchange (long newval);
+
/// Explicitly return @c value_.
long value (void) const;
@@ -221,6 +224,9 @@ public:
/// Atomically assign <rhs> to @c value_.
ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long> &operator= (const ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long> &rhs);
+ /// Exchange value with @a newval.
+ unsigned long exchange (unsigned long newval);
+
/// Explicitly return @c value_.
unsigned long value (void) const;
diff --git a/ACE/ace/Atomic_Op.inl b/ACE/ace/Atomic_Op.inl
index 123df4dc505..714bfe9c1be 100644
--- a/ACE/ace/Atomic_Op.inl
+++ b/ACE/ace/Atomic_Op.inl
@@ -189,6 +189,22 @@ ACE_Atomic_Op<ACE_Thread_Mutex, long>::operator= (
}
ACE_INLINE long
+ACE_Atomic_Op<ACE_Thread_Mutex, long>::exchange (long newval)
+{
+#if defined (ACE_HAS_INTRINSIC_INTERLOCKED)
+ return ::_InterlockedExchange (const_cast<long *> (&this->value_), newval);
+#elif defined (WIN32)
+ return ::InterlockedExchange (const_cast<long *> (&this->value_), newval);
+#elif defined (ACE_HAS_VXATOMICLIB)
+ return ::vxAtomicSet (reinterpret_cast <atomic_t*>(const_cast<long *> (&this->value_)), newval);
+#elif defined (ACE_HAS_SOLARIS_ATOMIC_LIB)
+ return ::atomic_swap_ulong (reinterpret_cast<volatile unsigned long*>(&this->value_), newval);
+#else /* WIN32 */
+ return (*exchange_fn_) (&this->value_, newval);
+#endif /* WIN32 */
+}
+
+ACE_INLINE long
ACE_Atomic_Op<ACE_Thread_Mutex, long>::value (void) const
{
return this->value_;
@@ -373,6 +389,22 @@ ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::operator= (
}
ACE_INLINE unsigned long
+ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::exchange (unsigned long newval)
+{
+#if defined (ACE_HAS_INTRINSIC_INTERLOCKED)
+ return ::_InterlockedExchange (const_cast<long *> (reinterpret_cast<volatile long*> (&this->value_)), newval);
+#elif defined (WIN32)
+ return ::InterlockedExchange (const_cast<long *> (reinterpret_cast<volatile long*> (&this->value_)), newval);
+#elif defined (ACE_HAS_VXATOMICLIB)
+ return ::vxAtomicSet (reinterpret_cast <atomic_t*>(const_cast<long *> (reinterpret_cast<volatile long*> (&this->value_))), newval);
+#elif defined (ACE_HAS_SOLARIS_ATOMIC_LIB)
+ return ::atomic_swap_ulong (&this->value_, newval);
+#else /* WIN32 */
+ return (*exchange_fn_) (reinterpret_cast<volatile long *> (&this->value_), newval);
+#endif /* WIN32 */
+}
+
+ACE_INLINE unsigned long
ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long>::value (void) const
{
return this->value_;
diff --git a/ACE/ace/Atomic_Op_GCC_T.h b/ACE/ace/Atomic_Op_GCC_T.h
index 348be5e95e0..a8dfc2b641a 100644
--- a/ACE/ace/Atomic_Op_GCC_T.h
+++ b/ACE/ace/Atomic_Op_GCC_T.h
@@ -74,6 +74,9 @@ public:
/// Atomically check if @c value_ less than rhs.
bool operator< (T rhs) const;
+ /// Exchange value with @a newval.
+ T exchange (T newval);
+
/// Explicitly return @c value_.
T value (void) const;
diff --git a/ACE/ace/Atomic_Op_GCC_T.inl b/ACE/ace/Atomic_Op_GCC_T.inl
index de3bf1a1438..8a914c65c1a 100644
--- a/ACE/ace/Atomic_Op_GCC_T.inl
+++ b/ACE/ace/Atomic_Op_GCC_T.inl
@@ -130,6 +130,13 @@ ACE_Atomic_Op_GCC<T>::operator= (
template <typename T>
ACE_INLINE T
+ACE_Atomic_Op_GCC<T>::exchange (T newval)
+{
+ return __sync_val_compare_and_swap (&this->value_, this->value_, newval);
+}
+
+template <typename T>
+ACE_INLINE T
ACE_Atomic_Op_GCC<T>::value (void) const
{
return this->value_;
diff --git a/ACE/ace/Atomic_Op_T.h b/ACE/ace/Atomic_Op_T.h
index 75ca728351a..1e3c53a3f3a 100644
--- a/ACE/ace/Atomic_Op_T.h
+++ b/ACE/ace/Atomic_Op_T.h
@@ -207,6 +207,9 @@ public:
ACE_Atomic_Op_Ex<ACE_LOCK, TYPE> &operator= (
ACE_Atomic_Op_Ex<ACE_LOCK, TYPE> const & rhs);
+ /// Exchange value with @a newval.
+ TYPE exchange (TYPE newval);
+
/// Explicitly return @c value_.
TYPE value (void) const;
@@ -318,6 +321,9 @@ public:
/// Atomically check if @c value_ less than @a rhs.
bool operator< (arg_type rhs) const;
+ /// Exchange value with @a newval.
+ TYPE exchange (TYPE newval);
+
/// Explicitly return @c value_.
TYPE value (void) const;
diff --git a/ACE/ace/Atomic_Op_T.inl b/ACE/ace/Atomic_Op_T.inl
index def9e9a435d..df549538e2b 100644
--- a/ACE/ace/Atomic_Op_T.inl
+++ b/ACE/ace/Atomic_Op_T.inl
@@ -154,6 +154,16 @@ ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::operator= (
template <class ACE_LOCK, class TYPE>
ACE_INLINE TYPE
+ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::exchange (TYPE newval)
+{
+ // ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::exchange");
+ ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, this->value_);
+ std::swap (this->value_, newval);
+ return newval;
+}
+
+template <class ACE_LOCK, class TYPE>
+ACE_INLINE TYPE
ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::value (void) const
{
// ACE_TRACE ("ACE_Atomic_Op_Ex<ACE_LOCK, TYPE>::value");
@@ -308,6 +318,13 @@ ACE_Atomic_Op<ACE_LOCK, TYPE>::operator< (
template <class ACE_LOCK, class TYPE>
ACE_INLINE TYPE
+ACE_Atomic_Op<ACE_LOCK, TYPE>::exchange (TYPE newval)
+{
+ return this->impl_.exchange (newval);
+}
+
+template <class ACE_LOCK, class TYPE>
+ACE_INLINE TYPE
ACE_Atomic_Op<ACE_LOCK, TYPE>::value (void) const
{
return this->impl_.value ();