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:
Ingo Weinhold
2003-06-25 00:00:34 +00:00
parent eba400a809
commit 86e8beea7d
2 changed files with 5 additions and 5 deletions
@@ -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);