1// 2// $Id: Locker.h,v 1.1 2002/07/09 12:24:33 ejakowatz Exp $ 3// 4// This is the BLocker interface for OpenBeOS. It has been created to 5// be source and binary compatible with the BeOS version of BLocker. 6// 7// bonefish: Removed virtual from destructor. 8 9 10#ifndef _OPENBEOS_LOCKER_H 11#define _OPENBEOS_LOCKER_H 12 13 14#include <OS.h> 15#include <SupportDefs.h> 16 17 18#ifdef USE_OPENBEOS_NAMESPACE 19namespace OpenBeOS { 20#endif 21 22class BLocker { 23public: 24 BLocker(); 25 BLocker(const char *name); 26 BLocker(bool benaphore_style); 27 BLocker(const char *name, bool benaphore_style); 28 29 // The following constructor is not documented in the BeBook 30 // and is only listed here to ensure binary compatibility. 31 // DO NOT USE THIS CONSTRUCTOR! 32 BLocker(const char *name, bool benaphore_style, bool); 33 34 ~BLocker(); 35 36 bool Lock(void); 37 status_t LockWithTimeout(bigtime_t timeout); 38 void Unlock(void); 39 40 thread_id LockingThread(void) const; 41 bool IsLocked(void) const; 42 int32 CountLocks(void) const; 43 int32 CountLockRequests(void) const; 44 sem_id Sem(void) const; 45 46private: 47 void InitLocker(const char *name, bool benaphore_style); 48 bool AcquireLock(bigtime_t timeout, status_t *error); 49 50 int32 fBenaphoreCount; 51 sem_id fSemaphoreID; 52 thread_id fLockOwner; 53 int32 fRecursiveCount; 54 55 // Reserved space for future changes to BLocker 56 int32 fReservedSpace[4]; 57}; 58 59#ifdef USE_OPENBEOS_NAMESPACE 60} 61#endif 62 63#endif // _OPENBEOS_LOCKER_H 64