diff options
author | Muhammad Zahalqa <m@tryfinally.com> | 2020-08-06 18:50:25 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-06 17:50:25 +0200 |
commit | 5fe6c13e5b32fc63a027a79e0d5154481e5cfa24 (patch) | |
tree | 496547743395d71e4b0fc6c34e0188db62ebb6a3 /Libraries/LibThread/Lock.h | |
parent | 4d9d054386d75c3f7bae91cb9224593fdc0bb5fe (diff) | |
download | serenity-5fe6c13e5b32fc63a027a79e0d5154481e5cfa24.zip |
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.
Diffstat (limited to 'Libraries/LibThread/Lock.h')
-rw-r--r-- | Libraries/LibThread/Lock.h | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/Libraries/LibThread/Lock.h b/Libraries/LibThread/Lock.h index def18517ab..02c97a382f 100644 --- a/Libraries/LibThread/Lock.h +++ b/Libraries/LibThread/Lock.h @@ -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); } } |