Kernel: Remove unused ScopedLockRelease class

This commit is contained in:
Andreas Kling 2021-08-23 02:17:02 +02:00
parent 7006cb82bd
commit a8967388d3
Notes: sideshowbarker 2024-07-18 05:21:10 +09:00

View File

@ -154,52 +154,4 @@ private:
bool m_locked { true };
};
class ScopedLockRelease {
AK_MAKE_NONCOPYABLE(ScopedLockRelease);
public:
ScopedLockRelease& operator=(ScopedLockRelease&&) = delete;
ScopedLockRelease(Mutex& lock)
: m_lock(&lock)
, m_previous_mode(lock.force_unlock_if_locked(m_previous_recursions))
{
}
ScopedLockRelease(ScopedLockRelease&& from)
: m_lock(exchange(from.m_lock, nullptr))
, m_previous_mode(exchange(from.m_previous_mode, Mutex::Mode::Unlocked))
, m_previous_recursions(exchange(from.m_previous_recursions, 0))
{
}
~ScopedLockRelease()
{
if (m_lock && m_previous_mode != Mutex::Mode::Unlocked)
m_lock->restore_lock(m_previous_mode, m_previous_recursions);
}
void restore_lock()
{
VERIFY(m_lock);
if (m_previous_mode != Mutex::Mode::Unlocked) {
m_lock->restore_lock(m_previous_mode, m_previous_recursions);
m_previous_mode = Mutex::Mode::Unlocked;
m_previous_recursions = 0;
}
}
void do_not_restore()
{
VERIFY(m_lock);
m_previous_mode = Mutex::Mode::Unlocked;
m_previous_recursions = 0;
}
private:
Mutex* m_lock;
Mutex::Mode m_previous_mode;
u32 m_previous_recursions;
};
}