mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-07 19:57:45 +03:00
Kernel: Remove unused ScopedLockRelease class
This commit is contained in:
parent
7006cb82bd
commit
a8967388d3
Notes:
sideshowbarker
2024-07-18 05:21:10 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/a8967388d3b
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user