diff options
author | Jose <jose@zeroc.com> | 2009-12-16 23:24:32 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2009-12-16 23:24:32 +0100 |
commit | 2d9c9295db9dabf20e860755e59229c01e18363b (patch) | |
tree | 531454063b912e6c3a4ea2c2089b495f73396b45 /cpp/test/IceUtil/thread/StaticMutexTest.cpp | |
parent | bug 4492 - PHP demos don't build against RPMs (diff) | |
download | ice-2d9c9295db9dabf20e860755e59229c01e18363b.tar.bz2 ice-2d9c9295db9dabf20e860755e59229c01e18363b.tar.xz ice-2d9c9295db9dabf20e860755e59229c01e18363b.zip |
Remove StaticMutexTest & RWRecMutexTest
Diffstat (limited to 'cpp/test/IceUtil/thread/StaticMutexTest.cpp')
-rw-r--r-- | cpp/test/IceUtil/thread/StaticMutexTest.cpp | 153 |
1 files changed, 0 insertions, 153 deletions
diff --git a/cpp/test/IceUtil/thread/StaticMutexTest.cpp b/cpp/test/IceUtil/thread/StaticMutexTest.cpp deleted file mode 100644 index 958c0670cce..00000000000 --- a/cpp/test/IceUtil/thread/StaticMutexTest.cpp +++ /dev/null @@ -1,153 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -// -// We disable deprecation warning here, to allow clean compilation of -// of deprecated methods. -// -#ifdef _MSC_VER -# pragma warning( disable : 4996 ) -#endif - -#include <IceUtil/IceUtil.h> - -#include <StaticMutexTest.h> -#include <TestCommon.h> - -using namespace std; -using namespace IceUtil; - -static const string mutexTestName("static mutex"); - -static StaticMutex staticMutex = ICE_STATIC_MUTEX_INITIALIZER; - -class StaticMutexTestThread : public Thread -{ -public: - - StaticMutexTestThread() : - _tryLock(false) - { - } - - virtual void run() - { - StaticMutex::TryLock tlock(staticMutex); - test(!tlock.acquired()); - - { - Mutex::Lock lock(_tryLockMutex); - _tryLock = true; - } - _tryLockCond.signal(); - - StaticMutex::Lock lock(staticMutex); - } - - void - waitTryLock() - { - Mutex::Lock lock(_tryLockMutex); - while(!_tryLock) - { - _tryLockCond.wait(lock); - } - } - -private: - - bool _tryLock; - // - // Use native Condition variable here, not Monitor. - // - Cond _tryLockCond; - Mutex _tryLockMutex; -}; - -typedef Handle<StaticMutexTestThread> StaticMutexTestThreadPtr; - -StaticMutexTest::StaticMutexTest() : - TestBase(mutexTestName) -{ -} - -void -StaticMutexTest::run() -{ - StaticMutexTestThreadPtr t; - 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(); - } - - // - // TEST: Once the mutex has been released, the thread should - // acquire the mutex and then terminate. - // - control.join(); -} |