diff options
Diffstat (limited to 'cpp/test/IceUtil/thread/StaticMutexTest.cpp')
-rw-r--r-- | cpp/test/IceUtil/thread/StaticMutexTest.cpp | 148 |
1 files changed, 74 insertions, 74 deletions
diff --git a/cpp/test/IceUtil/thread/StaticMutexTest.cpp b/cpp/test/IceUtil/thread/StaticMutexTest.cpp index 7868b2a4b32..f42b7c4345a 100644 --- a/cpp/test/IceUtil/thread/StaticMutexTest.cpp +++ b/cpp/test/IceUtil/thread/StaticMutexTest.cpp @@ -24,32 +24,32 @@ class StaticMutexTestThread : public Thread public: StaticMutexTestThread() : - _tryLock(false) + _tryLock(false) { } virtual void run() - { - StaticMutex::TryLock tlock(staticMutex); - test(!tlock.acquired()); + { + StaticMutex::TryLock tlock(staticMutex); + test(!tlock.acquired()); - { - Mutex::Lock lock(_tryLockMutex); - _tryLock = true; - } - _tryLockCond.signal(); + { + Mutex::Lock lock(_tryLockMutex); + _tryLock = true; + } + _tryLockCond.signal(); - StaticMutex::Lock lock(staticMutex); + StaticMutex::Lock lock(staticMutex); } void waitTryLock() { - Mutex::Lock lock(_tryLockMutex); - while(!_tryLock) - { - _tryLockCond.wait(lock); - } + Mutex::Lock lock(_tryLockMutex); + while(!_tryLock) + { + _tryLockCond.wait(lock); + } } private: @@ -76,65 +76,65 @@ StaticMutexTest::run() ThreadControl control; { - StaticMutex::Lock lock(staticMutex); - - // LockT testing: - // - - test(lock.acquired()); - - try - { - lock.acquire(); - test(false); - } - catch(const ThreadLockedException&) - { - // Expected - } - - try - { - lock.tryAcquire(); - test(false); - } - catch(const ThreadLockedException&) - { - // Expected - } - - test(lock.acquired()); - lock.release(); - test(!lock.acquired()); - - try - { - lock.release(); - test(false); - } - catch(const ThreadLockedException&) - { - // Expected - } - - StaticMutex::TryLock lock2(staticMutex); - try - { - test(lock.tryAcquire() == false); - } - catch(const ThreadLockedException&) - { - } - lock2.release(); - test(lock.tryAcquire() == true); - test(lock.acquired()); - - // TEST: Start thread, try to acquire the mutex. - t = new StaticMutexTestThread; - control = t->start(); - - // TEST: Wait until the tryLock has been tested. - t->waitTryLock(); + StaticMutex::Lock lock(staticMutex); + + // LockT testing: + // + + test(lock.acquired()); + + try + { + lock.acquire(); + test(false); + } + catch(const ThreadLockedException&) + { + // Expected + } + + try + { + lock.tryAcquire(); + test(false); + } + catch(const ThreadLockedException&) + { + // Expected + } + + test(lock.acquired()); + lock.release(); + test(!lock.acquired()); + + try + { + lock.release(); + test(false); + } + catch(const ThreadLockedException&) + { + // Expected + } + + StaticMutex::TryLock lock2(staticMutex); + try + { + test(lock.tryAcquire() == false); + } + catch(const ThreadLockedException&) + { + } + lock2.release(); + test(lock.tryAcquire() == true); + test(lock.acquired()); + + // TEST: Start thread, try to acquire the mutex. + t = new StaticMutexTestThread; + control = t->start(); + + // TEST: Wait until the tryLock has been tested. + t->waitTryLock(); } // |