mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:37:43 +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:
parent
4d9d054386
commit
5fe6c13e5b
1 changed files with 2 additions and 3 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue