mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-24 13:43:04 +00:00
SeqCst->Relaxed in doc examples.
SeqCst is unnecessary here.
This commit is contained in:
parent
f296c162d8
commit
a2c74b8445
@ -233,7 +233,7 @@ macro_rules! acquire {
|
||||
/// let val = Arc::clone(&val);
|
||||
///
|
||||
/// thread::spawn(move || {
|
||||
/// let v = val.fetch_add(1, Ordering::SeqCst);
|
||||
/// let v = val.fetch_add(1, Ordering::Relaxed);
|
||||
/// println!("{v:?}");
|
||||
/// });
|
||||
/// }
|
||||
|
@ -24,10 +24,7 @@ use crate::ptr;
|
||||
/// use std::alloc::{GlobalAlloc, Layout};
|
||||
/// use std::cell::UnsafeCell;
|
||||
/// use std::ptr::null_mut;
|
||||
/// use std::sync::atomic::{
|
||||
/// AtomicUsize,
|
||||
/// Ordering::{Acquire, SeqCst},
|
||||
/// };
|
||||
/// use std::sync::atomic::{AtomicUsize, Ordering::Relaxed};
|
||||
///
|
||||
/// const ARENA_SIZE: usize = 128 * 1024;
|
||||
/// const MAX_SUPPORTED_ALIGN: usize = 4096;
|
||||
@ -61,7 +58,7 @@ use crate::ptr;
|
||||
/// let mut allocated = 0;
|
||||
/// if self
|
||||
/// .remaining
|
||||
/// .fetch_update(SeqCst, SeqCst, |mut remaining| {
|
||||
/// .fetch_update(Relaxed, Relaxed, |mut remaining| {
|
||||
/// if size > remaining {
|
||||
/// return None;
|
||||
/// }
|
||||
@ -81,7 +78,7 @@ use crate::ptr;
|
||||
///
|
||||
/// fn main() {
|
||||
/// let _s = format!("allocating a string!");
|
||||
/// let currently = ALLOCATOR.remaining.load(Acquire);
|
||||
/// let currently = ALLOCATOR.remaining.load(Relaxed);
|
||||
/// println!("allocated so far: {}", ARENA_SIZE - currently);
|
||||
/// }
|
||||
/// ```
|
||||
|
Loading…
Reference in New Issue
Block a user