mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-25 05:55:13 +00:00
Kernel: Minor Lock optimization
This commit is contained in:
parent
b4c9e85056
commit
66f46d03e4
Notes:
sideshowbarker
2024-07-19 01:26:54 +09:00
Author: https://github.com/tomuta Commit: https://github.com/SerenityOS/serenity/commit/66f46d03e4a Pull-request: https://github.com/SerenityOS/serenity/pull/4042
1 changed files with 2 additions and 4 deletions
|
@ -52,8 +52,7 @@ void Lock::lock(Mode mode)
|
|||
}
|
||||
auto current_thread = Thread::current();
|
||||
for (;;) {
|
||||
bool expected = false;
|
||||
if (m_lock.compare_exchange_strong(expected, true, AK::memory_order_acq_rel)) {
|
||||
if (m_lock.exchange(true, AK::memory_order_acq_rel) == false) {
|
||||
do {
|
||||
// FIXME: Do not add new readers if writers are queued.
|
||||
bool modes_dont_conflict = !modes_conflict(m_mode, mode);
|
||||
|
@ -91,8 +90,7 @@ void Lock::unlock()
|
|||
{
|
||||
auto current_thread = Thread::current();
|
||||
for (;;) {
|
||||
bool expected = false;
|
||||
if (m_lock.compare_exchange_strong(expected, true, AK::memory_order_acq_rel)) {
|
||||
if (m_lock.exchange(true, AK::memory_order_acq_rel) == false) {
|
||||
ASSERT(m_times_locked);
|
||||
--m_times_locked;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue