Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 60ad490

Browse files
committed
SeqCst->Relaxed in pal::windows::pipe.
Relaxed is enough to ensure fetch_add(1) returns each integer exactly once.
1 parent 46bb073 commit 60ad490

File tree

1 file changed

+4
-4
lines changed
  • library/std/src/sys/pal/windows

1 file changed

+4
-4
lines changed

library/std/src/sys/pal/windows/pipe.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::path::Path;
77
use crate::ptr;
88
use crate::slice;
99
use crate::sync::atomic::AtomicUsize;
10-
use crate::sync::atomic::Ordering::SeqCst;
10+
use crate::sync::atomic::Ordering::Relaxed;
1111
use crate::sys::c;
1212
use crate::sys::fs::{File, OpenOptions};
1313
use crate::sys::handle::Handle;
@@ -214,11 +214,11 @@ pub fn spawn_pipe_relay(
214214
fn random_number() -> usize {
215215
static N: AtomicUsize = AtomicUsize::new(0);
216216
loop {
217-
if N.load(SeqCst) != 0 {
218-
return N.fetch_add(1, SeqCst);
217+
if N.load(Relaxed) != 0 {
218+
return N.fetch_add(1, Relaxed);
219219
}
220220

221-
N.store(hashmap_random_keys().0 as usize, SeqCst);
221+
N.store(hashmap_random_keys().0 as usize, Relaxed);
222222
}
223223
}
224224

0 commit comments

Comments
 (0)