Skip to content

Commit a2c74b8

Browse files
committed
SeqCst->Relaxed in doc examples.
SeqCst is unnecessary here.
1 parent f296c16 commit a2c74b8

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

library/alloc/src/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ macro_rules! acquire {
233233
/// let val = Arc::clone(&val);
234234
///
235235
/// thread::spawn(move || {
236-
/// let v = val.fetch_add(1, Ordering::SeqCst);
236+
/// let v = val.fetch_add(1, Ordering::Relaxed);
237237
/// println!("{v:?}");
238238
/// });
239239
/// }

library/core/src/alloc/global.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ use crate::ptr;
2424
/// use std::alloc::{GlobalAlloc, Layout};
2525
/// use std::cell::UnsafeCell;
2626
/// use std::ptr::null_mut;
27-
/// use std::sync::atomic::{
28-
/// AtomicUsize,
29-
/// Ordering::{Acquire, SeqCst},
30-
/// };
27+
/// use std::sync::atomic::{AtomicUsize, Ordering::Relaxed};
3128
///
3229
/// const ARENA_SIZE: usize = 128 * 1024;
3330
/// const MAX_SUPPORTED_ALIGN: usize = 4096;
@@ -61,7 +58,7 @@ use crate::ptr;
6158
/// let mut allocated = 0;
6259
/// if self
6360
/// .remaining
64-
/// .fetch_update(SeqCst, SeqCst, |mut remaining| {
61+
/// .fetch_update(Relaxed, Relaxed, |mut remaining| {
6562
/// if size > remaining {
6663
/// return None;
6764
/// }
@@ -81,7 +78,7 @@ use crate::ptr;
8178
///
8279
/// fn main() {
8380
/// let _s = format!("allocating a string!");
84-
/// let currently = ALLOCATOR.remaining.load(Acquire);
81+
/// let currently = ALLOCATOR.remaining.load(Relaxed);
8582
/// println!("allocated so far: {}", ARENA_SIZE - currently);
8683
/// }
8784
/// ```

0 commit comments

Comments
 (0)