// ********************************************************************** // // Copyright (c) 2003-2005 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. // // ********************************************************************** #ifndef ICE_UTIL_ABSTRACT_MUTEX_H #define ICE_UTIL_ABSTRACT_MUTEX_H #include #include namespace IceUtil { class AbstractMutex { public: typedef LockT Lock; typedef TryLockT TryLock; virtual void lock() const = 0; virtual void unlock() const = 0; virtual bool tryLock() const = 0; }; template class AbstractMutexI : public AbstractMutex, public T { public: typedef LockT Lock; typedef TryLockT TryLock; virtual void lock() const { T::lock(); } virtual void unlock() const { T::unlock(); } virtual bool tryLock() const { return T::tryLock(); } virtual ~AbstractMutexI() {} }; template class AbstractMutexReadI : public AbstractMutex, public T { public: typedef LockT Lock; typedef TryLockT TryLock; virtual void lock() const { T::readLock(); } virtual void unlock() const { T::unlock(); } virtual bool tryLock() const { return T::tryReadLock(); } virtual ~AbstractMutexReadI() {} }; template class AbstractMutexWriteI : public AbstractMutex, public T { public: typedef LockT Lock; typedef TryLockT TryLock; virtual void lock() const { T::writeLock(); } virtual void unlock() const { T::unlock(); } virtual bool tryLock() const { return T::tryWriteLock(); } virtual ~AbstractMutexWriteI() {} }; } #endif