File tree 1 file changed +4
-1
lines changed
1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -731,7 +731,8 @@ const NOTIFIED: usize = 2;
731
731
/// specifying a maximum time to block the thread for.
732
732
///
733
733
/// * The [`unpark`] method on a [`Thread`] atomically makes the token available
734
- /// if it wasn't already.
734
+ /// if it wasn't already. Because the token is initially absent, [`unpark`]
735
+ /// followed by [`park`] will result in the second call returning immediately.
735
736
///
736
737
/// In other words, each [`Thread`] acts a bit like a spinlock that can be
737
738
/// locked and unlocked using `park` and `unpark`.
@@ -766,6 +767,8 @@ const NOTIFIED: usize = 2;
766
767
/// // Let some time pass for the thread to be spawned.
767
768
/// thread::sleep(Duration::from_millis(10));
768
769
///
770
+ /// // There is no race condition here, if `unpark`
771
+ /// // happens first, `park` will return immediately.
769
772
/// println!("Unpark the thread");
770
773
/// parked_thread.thread().unpark();
771
774
///
You can’t perform that action at this time.
0 commit comments