About swap(), docs say that: "using Acquire makes the store part of this operation Relaxed".
I understand this as:
let atom = AtomicBool::new(true);
let prev = atom.swap(false, Ordering::Acquire);
print!("hello");
is equivalent to:
let atom = AtomicBool::new(true);
let prev = atom.load(Ordering::Acquire);
atom.store(false, Ordering::Relaxed);
print!("hello");
which compiler can then rearrange to:
let atom = AtomicBool::new(true);
let prev = atom.load(Ordering::Acquire);
print!("hello");
atom.store(false, Ordering::Relaxed);
Is this correct? If yes, will "SeqCst" ordering also result in equivalent load, store separated with potential interleaving in between?
printwithout waiting for the store to be visible on other cores. As forSeqCst, the docs state that it is more or less equivalent toAcqRelfor load-with-store operations (i.e.swap).