Added InitCheck() method.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29487 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -17,6 +17,8 @@ class BLocker {
|
|||||||
BLocker(const char* name, bool benaphoreStyle);
|
BLocker(const char* name, bool benaphoreStyle);
|
||||||
virtual ~BLocker();
|
virtual ~BLocker();
|
||||||
|
|
||||||
|
status_t InitCheck() const;
|
||||||
|
|
||||||
bool Lock(void);
|
bool Lock(void);
|
||||||
status_t LockWithTimeout(bigtime_t timeout);
|
status_t LockWithTimeout(bigtime_t timeout);
|
||||||
void Unlock(void);
|
void Unlock(void);
|
||||||
|
|||||||
@@ -93,6 +93,13 @@ BLocker::~BLocker()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BLocker::InitCheck() const
|
||||||
|
{
|
||||||
|
return fSemaphoreID >= 0 ? B_OK : fSemaphoreID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BLocker::Lock(void)
|
BLocker::Lock(void)
|
||||||
{
|
{
|
||||||
@@ -141,7 +148,7 @@ BLocker::Unlock(void)
|
|||||||
release_sem(fSemaphoreID);
|
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.
|
// The lock is currently not acquired so there is no owner.
|
||||||
fLockOwner = B_ERROR;
|
fLockOwner = B_ERROR;
|
||||||
|
|
||||||
// The lock is currently not acquired so the recursive count is zero.
|
// The lock is currently not acquired so the recursive count is zero.
|
||||||
fRecursiveCount = 0;
|
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) {
|
if (status == B_OK) {
|
||||||
// Set the lock owner to this thread and increment the recursive count
|
// Set the lock owner to this thread and increment the recursive count
|
||||||
// by one. The recursive count is incremented because one more Unlock()
|
// by one. The recursive count is incremented because one more Unlock()
|
||||||
|
|||||||
Reference in New Issue
Block a user