* Added ReadLocker/WriteLocker classes to auto lock an rw_lock.
* Added *_init_etc() functions to the fs_shell. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26302 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
/*
|
||||
* Copyright 2008, Axel Dörfler, [email protected].
|
||||
* Copyright 2005-2007, Ingo Weinhold, [email protected]. All rights reserved.
|
||||
*
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef KERNEL_UTIL_AUTO_LOCKER_H
|
||||
@@ -50,6 +52,35 @@ public:
|
||||
// RecursiveLocker
|
||||
typedef AutoLocker<recursive_lock, RecursiveLockLocking> RecursiveLocker;
|
||||
|
||||
class ReadWriteLockReadLocking {
|
||||
public:
|
||||
inline bool Lock(rw_lock *lockable)
|
||||
{
|
||||
return rw_lock_read_lock(lockable) == B_OK;
|
||||
}
|
||||
|
||||
inline void Unlock(rw_lock *lockable)
|
||||
{
|
||||
rw_lock_read_unlock(lockable);
|
||||
}
|
||||
};
|
||||
|
||||
class ReadWriteLockWriteLocking {
|
||||
public:
|
||||
inline bool Lock(rw_lock *lockable)
|
||||
{
|
||||
return rw_lock_write_lock(lockable) == B_OK;
|
||||
}
|
||||
|
||||
inline void Unlock(rw_lock *lockable)
|
||||
{
|
||||
rw_lock_write_unlock(lockable);
|
||||
}
|
||||
};
|
||||
|
||||
typedef AutoLocker<rw_lock, ReadWriteLockReadLocking> ReadLocker;
|
||||
typedef AutoLocker<rw_lock, ReadWriteLockWriteLocking> WriteLocker;
|
||||
|
||||
// InterruptsLocking
|
||||
class InterruptsLocking {
|
||||
public:
|
||||
@@ -135,6 +166,8 @@ typedef AutoLocker<spinlock, InterruptsSpinLocking> InterruptsSpinLocker;
|
||||
using BPrivate::AutoLocker;
|
||||
using BPrivate::MutexLocker;
|
||||
using BPrivate::RecursiveLocker;
|
||||
using BPrivate::ReadLocker;
|
||||
using BPrivate::WriteLocker;
|
||||
using BPrivate::InterruptsLocker;
|
||||
using BPrivate::SpinLocker;
|
||||
using BPrivate::InterruptsSpinLocker;
|
||||
|
||||
Reference in New Issue
Block a user