@@ -445,31 +445,30 @@ class RwLock {
445
445
// Phase 6: do futex wait until the lock is available or timeout is
446
446
// reached.
447
447
bool timeout_flag = false ;
448
- if (!old.can_acquire <role>(get_preference ())) {
448
+ if (!old.can_acquire <role>(get_preference ()))
449
449
timeout_flag = (queue.wait <role>(serial_number, timeout, is_pshared) ==
450
450
-ETIMEDOUT);
451
451
452
- // Phase 7: unregister ourselves as a pending reader.
453
- {
454
- // Similarly, the unregister operation should also be an atomic
455
- // transaction.
456
- WaitingQueue::Guard guard = queue.acquire (is_pshared);
457
- guard.pending_count <role>()--;
458
- // Clear the flag if we are the last reader. The flag must be
459
- // cleared otherwise operations like trylock may fail even though
460
- // there is no competitors.
461
- if (guard.pending_count <role>() == 0 )
462
- State::fetch_clear_pending_bit<role>(state,
463
- cpp::MemoryOrder::RELAXED);
464
- }
452
+ // Phase 7: unregister ourselves as a pending reader.
453
+ {
454
+ // Similarly, the unregister operation should also be an atomic
455
+ // transaction.
456
+ WaitingQueue::Guard guard = queue.acquire (is_pshared);
457
+ guard.pending_count <role>()--;
458
+ // Clear the flag if we are the last reader. The flag must be
459
+ // cleared otherwise operations like trylock may fail even though
460
+ // there is no competitors.
461
+ if (guard.pending_count <role>() == 0 )
462
+ State::fetch_clear_pending_bit<role>(state,
463
+ cpp::MemoryOrder::RELAXED);
464
+ }
465
465
466
- // Phase 8: exit the loop is timeout is reached.
467
- if (timeout_flag)
468
- return LockResult::TimedOut;
466
+ // Phase 8: exit the loop is timeout is reached.
467
+ if (timeout_flag)
468
+ return LockResult::TimedOut;
469
469
470
- // Phase 9: reload the state and retry the acquisition.
471
- old = State::spin_reload<role>(state, get_preference (), spin_count);
472
- }
470
+ // Phase 9: reload the state and retry the acquisition.
471
+ old = State::spin_reload<role>(state, get_preference (), spin_count);
473
472
}
474
473
}
475
474
0 commit comments