mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-13 21:12:26 +00:00
Kernel: Tidy up the ScopedCritical class a little bit
This commit is contained in:
parent
0d851b1930
commit
3e0020e67d
Notes:
sideshowbarker
2024-07-19 05:07:20 +09:00
Author: https://github.com/awesomekling
Commit: 3e0020e67d
1 changed files with 20 additions and 25 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue