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 2012/06/06 23:11:31 UTC
svn commit: r1347132 - in /activemq/activemq-cpp/trunk/activemq-cpp/src:
main/decaf/util/concurrent/locks/ test/decaf/util/concurrent/locks/
Author: tabish
Date: Wed Jun 6 21:11:30 2012
New Revision: 1347132
URL: http://svn.apache.org/viewvc?rev=1347132&view=rev
Log:
Updates the unit tests and fixes issue with the ReentrantReadWriteLock to work around ThreadLocal not currently managing pointer values, essentially disable a cache in the lock, will enable it once the ThreadLocal impl is improved.
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantReadWriteLock.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/locks/ReentrantReadWriteLockTest.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/locks/ReentrantReadWriteLockTest.h
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantReadWriteLock.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantReadWriteLock.cpp?rev=1347132&r1=1347131&r2=1347132&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantReadWriteLock.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/ReentrantReadWriteLock.cpp Wed Jun 6 21:11:30 2012
@@ -74,7 +74,7 @@ namespace {
/** Returns the number of shared holds represented in count */
static int sharedCount(int c) {
- return c >> SHARED_SHIFT;
+ return ((unsigned int)c >> SHARED_SHIFT);
}
/** Returns the number of exclusive holds represented in count */
@@ -199,6 +199,8 @@ namespace {
}
}
--rh.count;
+ readHolds.set(rh);
+ cachedHoldCounter = rh;
}
for (;;) {
@@ -247,6 +249,8 @@ namespace {
}
rh.count++;
+ readHolds.set(rh);
+ cachedHoldCounter = rh;
}
return 1;
}
@@ -308,6 +312,7 @@ namespace {
readHolds.set(rh);
}
rh.count++;
+ readHolds.set(rh);
cachedHoldCounter = rh; // cache for release
}
return 1;
@@ -369,6 +374,8 @@ namespace {
readHolds.set(rh);
}
rh.count++;
+ readHolds.set(rh);
+ cachedHoldCounter = rh;
}
return true;
}
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/locks/ReentrantReadWriteLockTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/locks/ReentrantReadWriteLockTest.cpp?rev=1347132&r1=1347131&r2=1347132&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/locks/ReentrantReadWriteLockTest.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/locks/ReentrantReadWriteLockTest.cpp Wed Jun 6 21:11:30 2012
@@ -518,7 +518,7 @@ void ReentrantReadWriteLockTest::testWri
try {
t1.start();
t2.start();
- Thread::sleep( SHORT_DELAY_MS);
+ Thread::sleep(SHORT_DELAY_MS);
lock.readLock().unlock();
t1.join(MEDIUM_DELAY_MS);
t2.join(MEDIUM_DELAY_MS);
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/locks/ReentrantReadWriteLockTest.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/locks/ReentrantReadWriteLockTest.h?rev=1347132&r1=1347131&r2=1347132&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/locks/ReentrantReadWriteLockTest.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test/decaf/util/concurrent/locks/ReentrantReadWriteLockTest.h Wed Jun 6 21:11:30 2012
@@ -70,7 +70,7 @@ namespace locks {
CPPUNIT_TEST( testReadHoldingWriteLockFair3 );
CPPUNIT_TEST( testWriteHoldingWriteLockFair4 );
CPPUNIT_TEST( testTryLockWhenReadLocked );
-// CPPUNIT_TEST( testWriteAfterMultipleReadLocks );
+ CPPUNIT_TEST( testWriteAfterMultipleReadLocks );
CPPUNIT_TEST( testTryLockWhenReadLockedFair );
CPPUNIT_TEST( testWriteTryLockWhenReadLockedFair );
CPPUNIT_TEST( testWriteTryLockTimeout );