You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2009/05/08 12:32:16 UTC
svn commit: r772928 - in
/activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/decaf/util/concurrent/atomic:
AtomicBoolean.cpp AtomicInteger.cpp
Author: tabish
Date: Fri May 8 10:32:15 2009
New Revision: 772928
URL: http://svn.apache.org/viewvc?rev=772928&view=rev
Log:
Fix for AMQCPP-242
Modified:
activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/decaf/util/concurrent/atomic/AtomicBoolean.cpp
activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/decaf/util/concurrent/atomic/AtomicInteger.cpp
Modified: activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/decaf/util/concurrent/atomic/AtomicBoolean.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/decaf/util/concurrent/atomic/AtomicBoolean.cpp?rev=772928&r1=772927&r2=772928&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/decaf/util/concurrent/atomic/AtomicBoolean.cpp (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/decaf/util/concurrent/atomic/AtomicBoolean.cpp Fri May 8 10:32:15 2009
@@ -44,12 +44,7 @@
////////////////////////////////////////////////////////////////////////////////
bool AtomicBoolean::getAndSet( bool newValue ) {
- for(;;) {
- bool current = get();
- if( compareAndSet( current, newValue ) ) {
- return current;
- }
- }
+ return apr_atomic_xchg32( &this->value, newValue ) > 0 ? true : false;
}
////////////////////////////////////////////////////////////////////////////////
Modified: activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/decaf/util/concurrent/atomic/AtomicInteger.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/decaf/util/concurrent/atomic/AtomicInteger.cpp?rev=772928&r1=772927&r2=772928&view=diff
==============================================================================
--- activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/decaf/util/concurrent/atomic/AtomicInteger.cpp (original)
+++ activemq/activemq-cpp/branches/activemq-cpp-2.x/src/main/decaf/util/concurrent/atomic/AtomicInteger.cpp Fri May 8 10:32:15 2009
@@ -36,12 +36,7 @@
////////////////////////////////////////////////////////////////////////////////
int AtomicInteger::getAndSet( int newValue ) {
- for(;;) {
- int current = get();
- if( compareAndSet( current, newValue ) ) {
- return current;
- }
- }
+ return apr_atomic_xchg32( &this->value, newValue );
}
////////////////////////////////////////////////////////////////////////////////
@@ -56,9 +51,7 @@
////////////////////////////////////////////////////////////////////////////////
int AtomicInteger::getAndDecrement() {
- int previous = (int)this->value;
- apr_atomic_dec32( &this->value );
- return previous;
+ return apr_atomic_add32( &this->value, 0xFFFFFFFF );
}
////////////////////////////////////////////////////////////////////////////////
@@ -68,20 +61,17 @@
////////////////////////////////////////////////////////////////////////////////
int AtomicInteger::incrementAndGet() {
- apr_atomic_inc32( &this->value );
- return this->value;
+ return apr_atomic_inc32( &this->value ) + 1;
}
////////////////////////////////////////////////////////////////////////////////
int AtomicInteger::decrementAndGet() {
- apr_atomic_dec32( &this->value );
- return this->value;
+ return apr_atomic_add32( &this->value, 0xFFFFFFFF ) - 1;
}
////////////////////////////////////////////////////////////////////////////////
int AtomicInteger::addAndGet( int delta ) {
- apr_atomic_add32( &this->value, delta );
- return this->value;
+ return apr_atomic_add32( &this->value, delta ) + delta;
}
////////////////////////////////////////////////////////////////////////////////