1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 09:14:58 +00:00

Kernel: Rename ScopedSpinlock => SpinlockLocker

This matches MutexLocker, and doesn't sound like it's a lock itself.
This commit is contained in:
Andreas Kling 2021-08-22 01:49:22 +02:00
parent 55adace359
commit c922a7da09
78 changed files with 365 additions and 366 deletions

View file

@ -21,7 +21,7 @@ void Mutex::lock(Mode mode, [[maybe_unused]] LockLocation const& location)
VERIFY(mode != Mode::Unlocked);
auto current_thread = Thread::current();
ScopedSpinlock lock(m_lock);
SpinlockLocker lock(m_lock);
bool did_block = false;
Mode current_mode = m_mode;
switch (current_mode) {
@ -145,7 +145,7 @@ void Mutex::unlock()
// and also from within critical sections!
VERIFY(!Processor::current().in_irq());
auto current_thread = Thread::current();
ScopedSpinlock lock(m_lock);
SpinlockLocker lock(m_lock);
Mode current_mode = m_mode;
if constexpr (LOCK_TRACE_DEBUG) {
if (current_mode == Mode::Shared)
@ -196,7 +196,7 @@ void Mutex::unlock()
}
}
void Mutex::block(Thread& current_thread, Mode mode, ScopedSpinlock<Spinlock<u8>>& lock, u32 requested_locks)
void Mutex::block(Thread& current_thread, Mode mode, SpinlockLocker<Spinlock<u8>>& lock, u32 requested_locks)
{
auto& blocked_thread_list = thread_list_for_mode(mode);
VERIFY(!blocked_thread_list.contains(current_thread));
@ -255,7 +255,7 @@ auto Mutex::force_unlock_if_locked(u32& lock_count_to_restore) -> Mode
// and also from within critical sections!
VERIFY(!Processor::current().in_irq());
auto current_thread = Thread::current();
ScopedSpinlock lock(m_lock);
SpinlockLocker lock(m_lock);
auto current_mode = m_mode;
switch (current_mode) {
case Mode::Exclusive: {
@ -319,7 +319,7 @@ void Mutex::restore_lock(Mode mode, u32 lock_count, [[maybe_unused]] LockLocatio
VERIFY(!Processor::current().in_irq());
auto current_thread = Thread::current();
bool did_block = false;
ScopedSpinlock lock(m_lock);
SpinlockLocker lock(m_lock);
switch (mode) {
case Mode::Exclusive: {
auto previous_mode = m_mode;

View file

@ -39,12 +39,12 @@ public:
[[nodiscard]] Mode force_unlock_if_locked(u32&);
[[nodiscard]] bool is_locked() const
{
ScopedSpinlock lock(m_lock);
SpinlockLocker lock(m_lock);
return m_mode != Mode::Unlocked;
}
[[nodiscard]] bool own_lock() const
{
ScopedSpinlock lock(m_lock);
SpinlockLocker lock(m_lock);
if (m_mode == Mode::Exclusive)
return m_holder == Thread::current();
if (m_mode == Mode::Shared)
@ -77,7 +77,7 @@ private:
return mode == Mode::Exclusive ? m_blocked_threads_list_exclusive : m_blocked_threads_list_shared;
}
void block(Thread&, Mode, ScopedSpinlock<Spinlock<u8>>&, u32);
void block(Thread&, Mode, SpinlockLocker<Spinlock<u8>>&, u32);
void unblock_waiters(Mode);
const char* m_name { nullptr };

View file

@ -116,15 +116,14 @@ private:
};
template<typename LockType>
class [[nodiscard]] ScopedSpinlock {
AK_MAKE_NONCOPYABLE(ScopedSpinlock);
class [[nodiscard]] SpinlockLocker {
AK_MAKE_NONCOPYABLE(SpinlockLocker);
public:
ScopedSpinlock() = delete;
ScopedSpinlock& operator=(ScopedSpinlock&&) = delete;
SpinlockLocker() = delete;
SpinlockLocker& operator=(SpinlockLocker&&) = delete;
ScopedSpinlock(LockType& lock)
SpinlockLocker(LockType& lock)
: m_lock(&lock)
{
VERIFY(m_lock);
@ -132,7 +131,7 @@ public:
m_have_lock = true;
}
ScopedSpinlock(ScopedSpinlock&& from)
SpinlockLocker(SpinlockLocker&& from)
: m_lock(from.m_lock)
, m_prev_flags(from.m_prev_flags)
, m_have_lock(from.m_have_lock)
@ -142,7 +141,7 @@ public:
from.m_have_lock = false;
}
~ScopedSpinlock()
~SpinlockLocker()
{
if (m_lock && m_have_lock) {
m_lock->unlock(m_prev_flags);

View file

@ -39,7 +39,7 @@ private:
private:
U& m_value;
ScopedSpinlock<RecursiveSpinlock> m_locker;
SpinlockLocker<RecursiveSpinlock> m_locker;
};
auto lock_const() const { return Locked<T const>(m_value, m_spinlock); }