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