1 // SimpleLockable.h 2 // * PURPOSE 3 // Basic BLocker implementation of ILockable. 4 // 5 // * HISTORY 6 // e.moon 7jul99 Cortex rework. 7 // e.moon 13apr99 Begun (beDub) 8 9 #ifndef __SimpleLockable_H__ 10 #define __SimpleLockable_H__ 11 12 #include "ILockable.h" 13 #include <Locker.h> 14 15 #include "cortex_defs.h" 16 __BEGIN_CORTEX_NAMESPACE 17 18 class SimpleLockable : 19 public ILockable { 20 21 public: // *** ctor 22 virtual ~SimpleLockable() {} 23 SimpleLockable() {} 24 SimpleLockable(const char* name) : m_lock(name) {} 25 26 public: // *** ILockable impl. 27 virtual bool lock( 28 lock_t type=WRITE, 29 bigtime_t timeout=B_INFINITE_TIMEOUT) { 30 31 return m_lock.LockWithTimeout(timeout) == B_OK; 32 } 33 34 virtual bool unlock( 35 lock_t type=WRITE) { 36 m_lock.Unlock(); 37 return true; 38 } 39 40 virtual bool isLocked( 41 lock_t type=WRITE) const { 42 return m_lock.IsLocked(); 43 } 44 45 protected: // members 46 mutable BLocker m_lock; 47 }; 48 49 __END_CORTEX_NAMESPACE 50 #endif /*__SimpleLockable_H__*/ 51