File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 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;
806806/// In other words, each [`Thread`] acts a bit like a spinlock that can be
807807/// locked and unlocked using `park` and `unpark`.
808808///
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+ ///
809813/// The API is typically used by acquiring a handle to the current thread,
810814/// 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
812816/// thread calls [`unpark`] on the handle.
813817///
814818/// The motivation for this design is twofold:
@@ -829,6 +833,7 @@ const NOTIFIED: usize = 2;
829833/// .spawn(|| {
830834/// println!("Parking thread");
831835/// thread::park();
836+ /// // We *could* get here spuriously, i.e., way before the 10ms below are over!
832837/// println!("Thread unparked");
833838/// })
834839/// .unwrap();
You can’t perform that action at this time.
0 commit comments