File tree 1 file changed +8
-3
lines changed
1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 26
26
//! [1]: http://llvm.org/docs/LangRef.html#memory-model-for-concurrent-operations
27
27
//!
28
28
//! Atomic variables are safe to share between threads (they implement `Sync`)
29
- //! but they do not themselves provide the mechanism for sharing. The most
30
- //! common way to share an atomic variable is to put it into an `Arc` (an
29
+ //! but they do not themselves provide the mechanism for sharing and follow the
30
+ //! [threading model](../../../std/thread/index.html#the-threading-model) of rust.
31
+ //! The most common way to share an atomic variable is to put it into an `Arc` (an
31
32
//! atomically-reference-counted shared pointer).
32
33
//!
33
34
//! Most atomic types may be stored in static variables, initialized using
48
49
//! let spinlock = Arc::new(AtomicUsize::new(1));
49
50
//!
50
51
//! let spinlock_clone = spinlock.clone();
51
- //! thread::spawn(move|| {
52
+ //! let thread = thread::spawn(move|| {
52
53
//! spinlock_clone.store(0, Ordering::SeqCst);
53
54
//! });
54
55
//!
55
56
//! // Wait for the other thread to release the lock
56
57
//! while spinlock.load(Ordering::SeqCst) != 0 {}
58
+ //!
59
+ //! if let Err(panic) = thread.join() {
60
+ //! println!("Thread had an error: {:?}", panic);
61
+ //! }
57
62
//! }
58
63
//! ```
59
64
//!
You can’t perform that action at this time.
0 commit comments