Hey! I have two threads. First stores 1 to x and load y, second stores 1 to y and load x. But assert broke with messagethread 'main' panicked at 'x = 0, y = 0', src/main.rs:23:9
Why it possible with the SeqCst ordering?
use loom::thread; use loom::sync::atomic::{AtomicUsize, Ordering}; use loom::sync::Arc; fn main() { loom::model(|| { let x = Arc::new(AtomicUsize::new(0)); let y = Arc::new(AtomicUsize::new(0)); let x1 = x.clone(); let y1 = y.clone(); let x2 = x.clone(); let y2 = y.clone(); let child_x = thread::spawn(move || { x1.store(1, Ordering::SeqCst); y1.load(Ordering::SeqCst) }); let child_y = thread::spawn(move || { y2.store(1, Ordering::SeqCst); x2.load(Ordering::SeqCst) }); let res_x = child_x.join().unwrap(); let res_y = child_y.join().unwrap(); assert!(!(res_x == 0 && res_y == 0), "x = {}, y = {}", res_x, res_y); }) }
wvwwvwwv, codyps, cdolan and avl
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4