We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
lock_contended
1 parent 94d54ea commit 2e35ae3Copy full SHA for 2e35ae3
library/std/src/sys/unix/locks/queue_rwlock.rs
@@ -114,7 +114,7 @@ use crate::sync::atomic::{
114
use crate::sys_common::thread_info;
115
use crate::thread::Thread;
116
117
-const SPIN_COUNT: usize = 100;
+const SPIN_COUNT: usize = 6;
118
119
type State = *mut ();
120
type AtomicState = AtomicPtr<()>;
@@ -328,7 +328,9 @@ impl RwLock {
328
} else if state.addr() & QUEUED == 0 && count < SPIN_COUNT {
329
// If the lock is not available but no threads are queued, spin
330
// for a while.
331
- spin_loop();
+ for _ in 0..(1 << count) {
332
+ spin_loop();
333
+ }
334
state = self.state.load(Relaxed);
335
count += 1;
336
} else {
0 commit comments