From f451e14bc2943245b03ce6acd379c12d74351269 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Fri, 13 Mar 2009 02:05:10 +0000 Subject: [PATCH] Added InitCheck() method. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29487 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/support/Locker.h | 2 ++ src/kits/support/Locker.cpp | 13 ++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/headers/os/support/Locker.h b/headers/os/support/Locker.h index 50aeb1a78d..b6605d0924 100644 --- a/headers/os/support/Locker.h +++ b/headers/os/support/Locker.h @@ -17,6 +17,8 @@ class BLocker { BLocker(const char* name, bool benaphoreStyle); virtual ~BLocker(); + status_t InitCheck() const; + bool Lock(void); status_t LockWithTimeout(bigtime_t timeout); void Unlock(void); diff --git a/src/kits/support/Locker.cpp b/src/kits/support/Locker.cpp index 48c0b99dbb..0a25a21e70 100644 --- a/src/kits/support/Locker.cpp +++ b/src/kits/support/Locker.cpp @@ -93,6 +93,13 @@ BLocker::~BLocker() } +status_t +BLocker::InitCheck() const +{ + return fSemaphoreID >= 0 ? B_OK : fSemaphoreID; +} + + bool BLocker::Lock(void) { @@ -141,7 +148,7 @@ BLocker::Unlock(void) release_sem(fSemaphoreID); } } - } + } } @@ -206,7 +213,7 @@ BLocker::InitLocker(const char *name, bool benaphore) // The lock is currently not acquired so there is no owner. fLockOwner = B_ERROR; - + // The lock is currently not acquired so the recursive count is zero. fRecursiveCount = 0; } @@ -272,7 +279,7 @@ BLocker::AcquireLock(bigtime_t timeout, status_t *error) } } - // If the lock has successfully been acquired. + // If the lock has successfully been acquired. if (status == B_OK) { // Set the lock owner to this thread and increment the recursive count // by one. The recursive count is incremented because one more Unlock()