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
Notes:
sideshowbarker
2024-07-19 04:13:10 +09:00
Author: https://github.com/tryfinally Commit: https://github.com/SerenityOS/serenity/commit/5fe6c13e5b3 Pull-request: https://github.com/SerenityOS/serenity/pull/3013
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
Reference in a new issue