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
|
||||
//
|
||||
// Returns whether or not the calling thread owns a read lock or even a
|
||||
// write lock.
|
||||
// Returns whether or not the calling thread owns a read lock or, if
|
||||
// orWriteLock is true, at least a write lock.
|
||||
bool
|
||||
RWLocker::IsReadLocked() const
|
||||
RWLocker::IsReadLocked(bool orWriteLock) const
|
||||
{
|
||||
bool result = false;
|
||||
if (_AcquireBenaphore(fLock) == B_OK) {
|
||||
thread_id thread = find_thread(NULL);
|
||||
result = (thread == fWriter || _IndexOf(thread) >= 0);
|
||||
result = ((orWriteLock && thread == fWriter) || _IndexOf(thread) >= 0);
|
||||
_ReleaseBenaphore(fLock);
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -83,7 +83,7 @@ class RWLocker {
|
||||
bool ReadLock();
|
||||
status_t ReadLockWithTimeout(bigtime_t timeout);
|
||||
void ReadUnlock();
|
||||
bool IsReadLocked() const;
|
||||
bool IsReadLocked(bool orWriteLock = true) const;
|
||||
|
||||
bool WriteLock();
|
||||
status_t WriteLockWithTimeout(bigtime_t timeout);
|
||||
|
||||
Reference in New Issue
Block a user