* Base class of InterruptsLocker was accidentially private.
* Added class InterruptsSpinLocker, which disables interrupts and acquires a spinlock all in one. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22086 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
5461952df6
commit
be8990115c
@ -83,7 +83,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// InterruptsLocker
|
// InterruptsLocker
|
||||||
class InterruptsLocker : AutoLocker<int, InterruptsLocking> {
|
class InterruptsLocker : public AutoLocker<int, InterruptsLocking> {
|
||||||
public:
|
public:
|
||||||
inline InterruptsLocker(bool alreadyLocked = false,
|
inline InterruptsLocker(bool alreadyLocked = false,
|
||||||
bool lockIfNotLocked = true)
|
bool lockIfNotLocked = true)
|
||||||
@ -114,6 +114,39 @@ public:
|
|||||||
// SpinLocker
|
// SpinLocker
|
||||||
typedef AutoLocker<spinlock, SpinLocking> SpinLocker;
|
typedef AutoLocker<spinlock, SpinLocking> SpinLocker;
|
||||||
|
|
||||||
|
// InterruptsSpinLocking
|
||||||
|
class InterruptsSpinLocking {
|
||||||
|
public:
|
||||||
|
struct State {
|
||||||
|
State(spinlock* lock)
|
||||||
|
: lock(lock)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int state;
|
||||||
|
spinlock* lock;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline bool Lock(spinlock* lockable)
|
||||||
|
{
|
||||||
|
fState = disable_interrupts();
|
||||||
|
acquire_spinlock(lockable);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Unlock(spinlock* lockable)
|
||||||
|
{
|
||||||
|
release_spinlock(lockable);
|
||||||
|
restore_interrupts(fState);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
int fState;
|
||||||
|
};
|
||||||
|
|
||||||
|
// InterruptsSpinLocker
|
||||||
|
typedef AutoLocker<spinlock, InterruptsSpinLocking> InterruptsSpinLocker;
|
||||||
|
|
||||||
} // namespace BPrivate
|
} // namespace BPrivate
|
||||||
|
|
||||||
using BPrivate::AutoLocker;
|
using BPrivate::AutoLocker;
|
||||||
@ -122,5 +155,6 @@ using BPrivate::RecursiveLocker;
|
|||||||
using BPrivate::BenaphoreLocker;
|
using BPrivate::BenaphoreLocker;
|
||||||
using BPrivate::InterruptsLocker;
|
using BPrivate::InterruptsLocker;
|
||||||
using BPrivate::SpinLocker;
|
using BPrivate::SpinLocker;
|
||||||
|
using BPrivate::InterruptsSpinLocker;
|
||||||
|
|
||||||
#endif // KERNEL_UTIL_AUTO_LOCKER_H
|
#endif // KERNEL_UTIL_AUTO_LOCKER_H
|
||||||
|
Loading…
Reference in New Issue
Block a user