Added boolean parameter to IsReadLocked() to specify when a write lock shall not be considered as read lock.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3653 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -118,15 +118,15 @@ RWLocker::ReadUnlock()
|
|||||||
|
|
||||||
// IsReadLocked
|
// IsReadLocked
|
||||||
//
|
//
|
||||||
// Returns whether or not the calling thread owns a read lock or even a
|
// Returns whether or not the calling thread owns a read lock or, if
|
||||||
// write lock.
|
// orWriteLock is true, at least a write lock.
|
||||||
bool
|
bool
|
||||||
RWLocker::IsReadLocked() const
|
RWLocker::IsReadLocked(bool orWriteLock) const
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
if (_AcquireBenaphore(fLock) == B_OK) {
|
if (_AcquireBenaphore(fLock) == B_OK) {
|
||||||
thread_id thread = find_thread(NULL);
|
thread_id thread = find_thread(NULL);
|
||||||
result = (thread == fWriter || _IndexOf(thread) >= 0);
|
result = ((orWriteLock && thread == fWriter) || _IndexOf(thread) >= 0);
|
||||||
_ReleaseBenaphore(fLock);
|
_ReleaseBenaphore(fLock);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class RWLocker {
|
|||||||
bool ReadLock();
|
bool ReadLock();
|
||||||
status_t ReadLockWithTimeout(bigtime_t timeout);
|
status_t ReadLockWithTimeout(bigtime_t timeout);
|
||||||
void ReadUnlock();
|
void ReadUnlock();
|
||||||
bool IsReadLocked() const;
|
bool IsReadLocked(bool orWriteLock = true) const;
|
||||||
|
|
||||||
bool WriteLock();
|
bool WriteLock();
|
||||||
status_t WriteLockWithTimeout(bigtime_t timeout);
|
status_t WriteLockWithTimeout(bigtime_t timeout);
|
||||||
|
|||||||
Reference in New Issue
Block a user