File tree 1 file changed +6
-1
lines changed
1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -806,9 +806,13 @@ const NOTIFIED: usize = 2;
806
806
/// In other words, each [`Thread`] acts a bit like a spinlock that can be
807
807
/// locked and unlocked using `park` and `unpark`.
808
808
///
809
+ /// Notice that it would be a valid (but inefficient) implementation to make both [`park`] and
810
+ /// [`unpark`] NOPs that return immediately. Being unblocked does not imply
811
+ /// any synchronization with someone that unparked this thread, it could also be spurious.
812
+ ///
809
813
/// The API is typically used by acquiring a handle to the current thread,
810
814
/// placing that handle in a shared data structure so that other threads can
811
- /// find it, and then `park`ing. When some desired condition is met, another
815
+ /// find it, and then `park`ing in a loop . When some desired condition is met, another
812
816
/// thread calls [`unpark`] on the handle.
813
817
///
814
818
/// The motivation for this design is twofold:
@@ -829,6 +833,7 @@ const NOTIFIED: usize = 2;
829
833
/// .spawn(|| {
830
834
/// println!("Parking thread");
831
835
/// thread::park();
836
+ /// // We *could* get here spuriously, i.e., way before the 10ms below are over!
832
837
/// println!("Thread unparked");
833
838
/// })
834
839
/// .unwrap();
You can’t perform that action at this time.
0 commit comments