* 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:
Axel Dörfler
2008-07-07 18:12:33 +00:00
parent e2dfe00484
commit 06d5e1b3b6
3 changed files with 78 additions and 0 deletions
+33
View File
@@ -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;