1 // 2 // $Id: Locker.h,v 1.1 2002/07/09 12:24:33 ejakowatz Exp $ 3 // 4 // This is the Locker interface for OpenBeOS. It has been created to 5 // be source and binary compatible with the BeOS version of Locker. 6 // 7 // bonefish: 8 // * Removed `virtual' from destructor and FBC reserved space. 9 // * Renamed to Locker. 10 11 12 #ifndef _OPENBEOS_LOCKER_H 13 #define _OPENBEOS_LOCKER_H 14 15 16 #include <OS.h> 17 #include <SupportDefs.h> 18 19 namespace UserlandFSUtil { 20 21 class Locker { 22 public: 23 Locker(); 24 Locker(const char *name); 25 Locker(bool benaphore_style); 26 Locker(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 Locker(const char *name, bool benaphore_style, bool); 32 33 ~Locker(); 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 55 } // namespace UserlandFSUtil 56 57 using UserlandFSUtil::Locker; 58 59 #endif // _OPENBEOS_LOCKER_H 60