We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 91ab308 commit bc59557Copy full SHA for bc59557
library/std/src/thread/id.rs
@@ -70,7 +70,9 @@ impl ThreadId {
70
71
// Acquire lock.
72
let mut spin = 0;
73
- while COUNTER_LOCKED.compare_exchange_weak(false, true, Ordering::Acquire, Ordering::Relaxed).is_err() {
+ // Miri doesn't like it when we yield here as it interferes with deterministically
74
+ // scheduling threads, so use `compare_exchange` to avoid spurious yields.
75
+ while COUNTER_LOCKED.compare_exchange(false, true, Ordering::Acquire, Ordering::Relaxed).is_err() {
76
if spin <= 3 {
77
for _ in 0..(1 << spin) {
78
spin_loop();
0 commit comments