1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:17:35 +00:00

Kernel: Tidy up the ScopedCritical class a little bit

This commit is contained in:
Andreas Kling 2020-07-06 11:27:07 +02:00
parent 0d851b1930
commit 3e0020e67d

View file

@ -804,15 +804,10 @@ public:
void set_thread_specific(u8* data, size_t len);
};
class ScopedCritical
{
u32 m_prev_flags;
bool m_valid;
class ScopedCritical {
AK_MAKE_NONCOPYABLE(ScopedCritical);
public:
ScopedCritical(const ScopedCritical&) = delete;
ScopedCritical& operator=(const ScopedCritical&) = delete;
ScopedCritical()
{
m_valid = true;
@ -827,24 +822,24 @@ public:
}
}
ScopedCritical(ScopedCritical&& from):
m_prev_flags(from.m_prev_flags),
m_valid(from.m_valid)
ScopedCritical(ScopedCritical&& from)
: m_prev_flags(exchange(from.m_prev_flags, 0))
, m_valid(exchange(from.m_valid, false))
{
from.m_prev_flags = 0;
from.m_valid = false;
}
ScopedCritical& operator=(ScopedCritical&& from)
{
if (&from != this) {
m_prev_flags = from.m_prev_flags;
m_valid = from.m_valid;
from.m_prev_flags = 0;
from.m_valid = false;
m_prev_flags = exchange(from.m_prev_flags, 0);
m_valid = exchange(from.m_valid, false);
}
return *this;
}
private:
u32 m_prev_flags { 0 };
bool m_valid { false };
};
struct TrapFrame {