mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +00:00
LibThread: Remove redundant r/w of atomic variable in Lock::lock() (#3013)
m_holder.compare_exchange_strong(expected, desired, ...) will either successfully update the value to desired if == expected or put the current value in expected otherwise.
This commit is contained in:
@@ -72,12 +72,11 @@ ALWAYS_INLINE void Lock::lock()
|
||||
}
|
||||
for (;;) {
|
||||
int expected = 0;
|
||||
if (m_holder.compare_exchange_strong(expected, tid, AK::memory_order_acq_rel)) {
|
||||
m_holder = tid;
|
||||
if (m_holder.compare_exchange_strong(expected, tid, AK::memory_order_acq_rel)) {
|
||||
m_level = 1;
|
||||
return;
|
||||
}
|
||||
donate(m_holder);
|
||||
donate(expected);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user