Fixed an initialization problem of the ReadWriteLock pointed out by geist, also added a comment on how the ownership is used when doing read locking. Thanks!
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21314 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
/* Lock - simple semaphores, read/write lock implementation
|
||||
* Roughly based on a Be sample code written by Nathan Schrenk.
|
||||
/*
|
||||
*
|
||||
* Copyright 2001-2006, Axel Dörfler, [email protected].
|
||||
* Copyright 2001-2007, Axel Dörfler, [email protected].
|
||||
* This file may be used under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef LOCK_H
|
||||
#define LOCK_H
|
||||
|
||||
/*! Simple semaphores, read/write lock implementation
|
||||
Roughly based on a Be sample code written by Nathan Schrenk.
|
||||
*/
|
||||
|
||||
#include "system_dependencies.h"
|
||||
|
||||
#include "Utility.h"
|
||||
@@ -333,11 +336,16 @@ class ReadWriteLock {
|
||||
class ReadWriteLock {
|
||||
public:
|
||||
ReadWriteLock(const char *name)
|
||||
:
|
||||
fOwner(-1)
|
||||
{
|
||||
Initialize(name);
|
||||
}
|
||||
|
||||
ReadWriteLock()
|
||||
:
|
||||
fSemaphore(-1),
|
||||
fOwner(-1)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -362,6 +370,7 @@ class ReadWriteLock {
|
||||
|
||||
status_t Lock()
|
||||
{
|
||||
// This allows nested locking when holding a write lock
|
||||
thread_id currentThread = find_thread(NULL);
|
||||
if (currentThread == fOwner) {
|
||||
fOwnerCount++;
|
||||
|
||||
Reference in New Issue
Block a user