We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 709ccf9 commit 61ce691Copy full SHA for 61ce691
library/std/src/sys/pal/unix/locks/queue_rwlock.rs
@@ -325,8 +325,9 @@ impl RwLock {
325
Ok(_) => return,
326
Err(new) => state = new,
327
}
328
- } else if count < SPIN_COUNT {
329
- // If the lock is not available, spin for a while.
+ } else if state.addr() & QUEUED == 0 && count < SPIN_COUNT {
+ // If the lock is not available but no threads are queued, spin
330
+ // for a while.
331
spin_loop();
332
state = self.state.load(Relaxed);
333
count += 1;
0 commit comments