summaryrefslogtreecommitdiff
path: root/cpp/test/IceUtil/thread/RecMutexTest.cpp
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2003-04-16 04:24:18 +0000
committerBernard Normier <bernard@zeroc.com>2003-04-16 04:24:18 +0000
commit3c99b3b3923f419eb3c2934fb017dadea6180fc6 (patch)
treec61d296def71d4c261637ef1297706883bf17d94 /cpp/test/IceUtil/thread/RecMutexTest.cpp
parenta link cost of 0 means accept all messages regardless of cost (diff)
downloadice-3c99b3b3923f419eb3c2934fb017dadea6180fc6.tar.bz2
ice-3c99b3b3923f419eb3c2934fb017dadea6180fc6.tar.xz
ice-3c99b3b3923f419eb3c2934fb017dadea6180fc6.zip
Mutex and Lock changes: lock/unlock now return void, trylock returns a bool
that indicates whether the lock was acquired or not, plus new member functions on LockT/TryLockT
Diffstat (limited to 'cpp/test/IceUtil/thread/RecMutexTest.cpp')
-rw-r--r--cpp/test/IceUtil/thread/RecMutexTest.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/cpp/test/IceUtil/thread/RecMutexTest.cpp b/cpp/test/IceUtil/thread/RecMutexTest.cpp
index 5a8a5c4a1c1..da5fab6c03c 100644
--- a/cpp/test/IceUtil/thread/RecMutexTest.cpp
+++ b/cpp/test/IceUtil/thread/RecMutexTest.cpp
@@ -34,17 +34,14 @@ public:
virtual void run()
{
- try
- {
- RecMutex::TryLock lock(_mutex);
- test(false);
- }
- catch(const ThreadLockedException&)
+
+ RecMutex::TryLock tlock(_mutex);
+ test(!tlock.acquired());
+
{
- // Expected
+ Mutex::Lock lock(_trylockMutex);
+ _trylock = true;
}
-
- _trylock = true;
_trylockCond.signal();
RecMutex::Lock lock(_mutex);
@@ -90,9 +87,10 @@ RecMutexTest::run()
// TEST: lock twice
RecMutex::Lock lock2(mutex);
-
+
// TEST: TryLock
RecMutex::TryLock lock3(mutex);
+ test(lock3.acquired());
// TEST: Start thread, try to acquire the mutex.
t = new RecMutexTestThread(mutex);
@@ -100,11 +98,14 @@ RecMutexTest::run()
// TEST: Wait until the trylock has been tested.
t->waitTrylock();
+
}
//
// TEST: Once the recursive mutex has been released, the thread
// should acquire the mutex and then terminate.
//
+
control.join();
+
}