activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1103208 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main: ./ decaf/internal/util/concurrent/ decaf/internal/util/concurrent/unix/ decaf/internal/util/concurrent/windows/ decaf/util/concurrent/atomic/
Date Sat, 14 May 2011 20:19:46 GMT
Author: tabish
Date: Sat May 14 20:19:46 2011
New Revision: 1103208

URL: http://svn.apache.org/viewvc?rev=1103208&view=rev
Log:
Refactor Atomics to allow Decaf to use raw atomic methods without need for the Atomic classes,
and make it easier to remove the use of APR atomics in favor of direct use of the platforms
atomic routines.  

Added:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/Atomics.h
  (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/unix/Atomics.cpp
  (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/windows/Atomics.cpp
  (with props)
Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/atomic/AtomicBoolean.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/atomic/AtomicBoolean.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/atomic/AtomicInteger.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/atomic/AtomicInteger.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/atomic/AtomicReference.h

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am?rev=1103208&r1=1103207&r2=1103208&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am Sat May 14 20:19:46 2011
@@ -321,6 +321,7 @@ cc_sources = \
     decaf/internal/util/TimerTaskHeap.cpp \
     decaf/internal/util/concurrent/SynchronizableImpl.cpp \
     decaf/internal/util/concurrent/Threading.cpp \
+    decaf/internal/util/concurrent/unix/Atomics.cpp \
     decaf/internal/util/concurrent/unix/PlatformThread.cpp \
     decaf/internal/util/zip/adler32.c \
     decaf/internal/util/zip/crc32.c \
@@ -460,6 +461,7 @@ cc_sources = \
     decaf/util/concurrent/atomic/AtomicRefCounter.cpp \
     decaf/util/concurrent/atomic/AtomicReference.cpp \
     decaf/util/concurrent/locks/AbstractOwnableSynchronizer.cpp \
+    decaf/util/concurrent/locks/AbstractQueuedSynchronizer.cpp \
     decaf/util/concurrent/locks/LockSupport.cpp \
     decaf/util/concurrent/locks/ReentrantLock.cpp \
     decaf/util/logging/ConsoleHandler.cpp \
@@ -835,6 +837,7 @@ h_sources = \
     decaf/internal/util/Resource.h \
     decaf/internal/util/ResourceLifecycleManager.h \
     decaf/internal/util/TimerTaskHeap.h \
+    decaf/internal/util/concurrent/Atomics.h \
     decaf/internal/util/concurrent/PlatformThread.h \
     decaf/internal/util/concurrent/SynchronizableImpl.h \
     decaf/internal/util/concurrent/Threading.h \
@@ -1056,6 +1059,7 @@ h_sources = \
     decaf/util/concurrent/atomic/AtomicRefCounter.h \
     decaf/util/concurrent/atomic/AtomicReference.h \
     decaf/util/concurrent/locks/AbstractOwnableSynchronizer.h \
+    decaf/util/concurrent/locks/AbstractQueuedSynchronizer.h \
     decaf/util/concurrent/locks/Condition.h \
     decaf/util/concurrent/locks/Lock.h \
     decaf/util/concurrent/locks/LockSupport.h \

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/Atomics.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/Atomics.h?rev=1103208&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/Atomics.h
(added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/Atomics.h
Sat May 14 20:19:46 2011
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DECAF_INTERNAL_UTIL_CONCURRENT_ATOMICS_H_
+#define _DECAF_INTERNAL_UTIL_CONCURRENT_ATOMICS_H_
+
+#include <decaf/util/Config.h>
+
+namespace decaf {
+namespace internal {
+namespace util {
+namespace concurrent {
+
+    class DECAF_API Atomics {
+    private:
+
+        Atomics();
+        Atomics(const Atomics&);
+        Atomics& operator= (const Atomics&);
+
+    public:
+
+        static bool compareAndSet32(volatile int* target, int expect, int update);
+        static bool compareAndSet(volatile void** target, void* expect, void* update);
+
+        static void* getAndSet(volatile void** target, void* value);
+        static int getAndSet(volatile int* target, int value);
+
+        static int getAndIncrement(volatile int* target);
+        static int getAndDecrement(volatile int* target);
+
+        static int getAndAdd(volatile int* target, int delta);
+        static int addAndGet(volatile int* target, int delta);
+
+        static int incrementAndGet(volatile int* target);
+        static int decrementAndGet(volatile int* target);
+
+    };
+
+}}}}
+
+#endif /* _DECAF_INTERNAL_UTIL_CONCURRENT_ATOMICS_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/Atomics.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/unix/Atomics.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/unix/Atomics.cpp?rev=1103208&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/unix/Atomics.cpp
(added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/unix/Atomics.cpp
Sat May 14 20:19:46 2011
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <decaf/internal/util/concurrent/Atomics.h>
+
+#include <apr_atomic.h>
+
+using namespace decaf::internal;
+using namespace decaf::internal::util;
+using namespace decaf::internal::util::concurrent;
+
+////////////////////////////////////////////////////////////////////////////////
+bool Atomics::compareAndSet32(volatile int* target, int expect, int update ) {
+    return apr_atomic_cas32((volatile apr_uint32_t*)target, update, expect) == (unsigned
int)expect;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Atomics::compareAndSet(volatile void** target, void* expect, void* update) {
+    return apr_atomic_casptr( target, (void*)update, (void*)expect ) == (void*)expect;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Atomics::getAndSet(volatile int* target, int newValue) {
+    return apr_atomic_xchg32((volatile apr_uint32_t*)target, newValue);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void* Atomics::getAndSet(volatile void** target, void* newValue) {
+    return apr_atomic_xchgptr(target, newValue);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Atomics::getAndIncrement(volatile int* target) {
+    return apr_atomic_inc32((volatile apr_uint32_t*)target);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Atomics::getAndDecrement(volatile int* target) {
+    return apr_atomic_add32((volatile apr_uint32_t*)target, 0xFFFFFFFF);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Atomics::getAndAdd(volatile int* target, int delta) {
+    return apr_atomic_add32((volatile apr_uint32_t*)target, delta);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Atomics::addAndGet(volatile int* target, int delta) {
+    return apr_atomic_add32((volatile apr_uint32_t*)target, delta) + delta;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Atomics::incrementAndGet(volatile int* target) {
+    return apr_atomic_inc32((volatile apr_uint32_t*)target) + 1;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Atomics::decrementAndGet(volatile int* target) {
+    return apr_atomic_add32((volatile apr_uint32_t*)target, 0xFFFFFFFF) - 1;
+}
+

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/unix/Atomics.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/windows/Atomics.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/windows/Atomics.cpp?rev=1103208&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/windows/Atomics.cpp
(added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/windows/Atomics.cpp
Sat May 14 20:19:46 2011
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <decaf/internal/util/concurrent/Atomics.h>
+
+using namespace decaf::internal;
+using namespace decaf::internal::util;
+using namespace decaf::internal::util::concurrent;
+
+////////////////////////////////////////////////////////////////////////////////
+bool Atomics::compareAndSet32(volatile int* target, int expect, int update ) {
+    return InterlockedCompareExchange((volatile apr_uint32_t*)target, update, expect) ==
(unsigned int)expect;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Atomics::compareAndSet(volatile void** target, void* expect, void* update) {
+    return InterlockedCompareExchangePointer( target, (void*)update, (void*)expect ) == (void*)expect;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Atomics::getAndSet(volatile int* target, int newValue) {
+    return InterlockedExchange((volatile apr_uint32_t*)target, newValue);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void* Atomics::getAndSet(volatile void** target, void* newValue) {
+    return InterlockedExchangePointer(target, newValue);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Atomics::getAndIncrement(volatile int* target) {
+    return InterlockedIncrement((volatile apr_uint32_t*)target);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Atomics::getAndDecrement(volatile int* target) {
+    return InterlockedExchangeAdd((volatile apr_uint32_t*)target, 0xFFFFFFFF);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Atomics::getAndAdd(volatile int* target, int delta) {
+    return InterlockedExchangeAdd((volatile apr_uint32_t*)target, delta);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Atomics::addAndGet(volatile int* target, int delta) {
+    return InterlockedExchangeAdd((volatile apr_uint32_t*)target, delta) + delta;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Atomics::incrementAndGet(volatile int* target) {
+    return InterlockedIncrement((volatile apr_uint32_t*)target) + 1;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Atomics::decrementAndGet(volatile int* target) {
+    return InterlockedExchangeAdd((volatile apr_uint32_t*)target, 0xFFFFFFFF) - 1;
+}
+

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/windows/Atomics.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/atomic/AtomicBoolean.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/atomic/AtomicBoolean.cpp?rev=1103208&r1=1103207&r2=1103208&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/atomic/AtomicBoolean.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/atomic/AtomicBoolean.cpp
Sat May 14 20:19:46 2011
@@ -18,13 +18,15 @@
 #include "AtomicBoolean.h"
 
 #include <decaf/lang/Boolean.h>
-#include <apr_atomic.h>
+
+#include <decaf/internal/util/concurrent/Atomics.h>
 
 using namespace decaf;
 using namespace decaf::lang;
 using namespace decaf::util;
 using namespace decaf::util::concurrent;
 using namespace decaf::util::concurrent::atomic;
+using namespace decaf::internal::util::concurrent;
 
 ////////////////////////////////////////////////////////////////////////////////
 AtomicBoolean::AtomicBoolean() : value(0) {
@@ -36,14 +38,14 @@ AtomicBoolean::AtomicBoolean( bool initi
 
 ////////////////////////////////////////////////////////////////////////////////
 bool AtomicBoolean::compareAndSet( bool expect, bool update ) {
-    unsigned int upd = update ? 1 : 0;
-    unsigned int exp = expect ? 1 : 0;
-    return apr_atomic_cas32( &this->value, upd, exp ) == exp;
+    int upd = update ? 1 : 0;
+    int exp = expect ? 1 : 0;
+    return Atomics::compareAndSet32(&this->value, exp, upd);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 bool AtomicBoolean::getAndSet( bool newValue ) {
-    return apr_atomic_xchg32( &this->value, newValue ) > 0 ? true : false;
+    return Atomics::getAndSet(&this->value, newValue) > 0 ? true : false;
 }
 
 ////////////////////////////////////////////////////////////////////////////////

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/atomic/AtomicBoolean.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/atomic/AtomicBoolean.h?rev=1103208&r1=1103207&r2=1103208&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/atomic/AtomicBoolean.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/atomic/AtomicBoolean.h
Sat May 14 20:19:46 2011
@@ -34,7 +34,7 @@ namespace atomic {
     class DECAF_API AtomicBoolean {
     private:
 
-        volatile unsigned int value;
+        volatile int value;
 
     public:
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/atomic/AtomicInteger.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/atomic/AtomicInteger.cpp?rev=1103208&r1=1103207&r2=1103208&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/atomic/AtomicInteger.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/atomic/AtomicInteger.cpp
Sat May 14 20:19:46 2011
@@ -18,65 +18,68 @@
 #include "AtomicInteger.h"
 
 #include <decaf/lang/Integer.h>
-#include <apr_atomic.h>
+#include <decaf/internal/util/concurrent/Atomics.h>
 
 using namespace decaf;
 using namespace decaf::lang;
 using namespace decaf::util;
 using namespace decaf::util::concurrent;
 using namespace decaf::util::concurrent::atomic;
+using namespace decaf::internal::util::concurrent;
 
 ////////////////////////////////////////////////////////////////////////////////
-AtomicInteger::AtomicInteger() : value( 0 ) {
+AtomicInteger::AtomicInteger() :
+    value(0) {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-AtomicInteger::AtomicInteger( int initialValue ) : value( initialValue ) {
+AtomicInteger::AtomicInteger(int initialValue) :
+    value(initialValue) {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-int AtomicInteger::getAndSet( int newValue ) {
-    return apr_atomic_xchg32( &this->value, newValue );
+int AtomicInteger::getAndSet(int newValue) {
+    return Atomics::getAndSet(&this->value, newValue);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-bool AtomicInteger::compareAndSet( int expect, int update ) {
-    return apr_atomic_cas32( &this->value, update, expect ) == (unsigned int)expect;
+bool AtomicInteger::compareAndSet(int expect, int update) {
+    return Atomics::compareAndSet32(&this->value, expect, update);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 int AtomicInteger::getAndIncrement() {
-    return apr_atomic_inc32( &this->value );
+    return Atomics::getAndIncrement(&this->value);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 int AtomicInteger::getAndDecrement() {
-    return apr_atomic_add32( &this->value, 0xFFFFFFFF );
+    return Atomics::getAndDecrement(&this->value);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-int AtomicInteger::getAndAdd( int delta ) {
-    return apr_atomic_add32( &this->value, delta );
+int AtomicInteger::getAndAdd(int delta) {
+    return Atomics::getAndAdd(&this->value, delta);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 int AtomicInteger::incrementAndGet() {
-    return apr_atomic_inc32( &this->value ) + 1;
+    return Atomics::incrementAndGet(&this->value);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 int AtomicInteger::decrementAndGet() {
-    return apr_atomic_add32( &this->value, 0xFFFFFFFF ) - 1;
+    return Atomics::decrementAndGet(&this->value);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-int AtomicInteger::addAndGet( int delta ) {
-    return apr_atomic_add32( &this->value, delta ) + delta;
+int AtomicInteger::addAndGet(int delta) {
+    return Atomics::addAndGet(&this->value, delta);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 std::string AtomicInteger::toString() const {
-    return Integer::toString( this->value );
+    return Integer::toString(this->value);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -86,15 +89,15 @@ int AtomicInteger::intValue() const {
 
 ////////////////////////////////////////////////////////////////////////////////
 long long AtomicInteger::longValue() const {
-    return Integer( value ).longValue();
+    return Integer(value).longValue();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 float AtomicInteger::floatValue() const {
-    return Integer( value ).floatValue();
+    return Integer(value).floatValue();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 double AtomicInteger::doubleValue() const {
-    return Integer( value ).doubleValue();
+    return Integer(value).doubleValue();
 }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/atomic/AtomicInteger.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/atomic/AtomicInteger.h?rev=1103208&r1=1103207&r2=1103208&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/atomic/AtomicInteger.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/atomic/AtomicInteger.h
Sat May 14 20:19:46 2011
@@ -37,7 +37,7 @@ namespace atomic {
     class DECAF_API AtomicInteger : public decaf::lang::Number {
     private:
 
-        volatile unsigned int value;
+        volatile int value;
 
     public:
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/atomic/AtomicReference.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/atomic/AtomicReference.h?rev=1103208&r1=1103207&r2=1103208&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/atomic/AtomicReference.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/atomic/AtomicReference.h
Sat May 14 20:19:46 2011
@@ -20,7 +20,7 @@
 
 #include <decaf/util/Config.h>
 #include <decaf/lang/Long.h>
-#include <apr_atomic.h>
+#include <decaf/internal/util/concurrent/Atomics.h>
 
 namespace decaf {
 namespace util {
@@ -57,7 +57,7 @@ namespace atomic {
          *        The new Value of this Reference.
          */
         void set( T* newValue ) {
-            apr_atomic_xchgptr( &this->value, (void*)newValue );
+            internal::util::concurrent::Atomics::getAndSet(&this->value, (void*)newValue);
         }
 
         /**
@@ -71,7 +71,7 @@ namespace atomic {
          *         not equal to the expected value.
          */
         bool compareAndSet( T* expect, T* update ) {
-            return apr_atomic_casptr( &this->value, (void*)update, (void*)expect )
== (void*)expect;
+            return internal::util::concurrent::Atomics::compareAndSet(&this->value,
(void*)expect, (void*)update);
         }
 
         /**
@@ -82,7 +82,7 @@ namespace atomic {
          * @return the previous value.
          */
         T* getAndSet( T* newValue ) {
-            return (T*)apr_atomic_xchgptr( &this->value, (void*)newValue );
+            return (T*)internal::util::concurrent::Atomics::getAndSet(&this->value,
(void*)newValue);
         }
 
         /**



Mime
View raw message