File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -458,6 +458,16 @@ pub fn yield_now() {
458458
459459/// Determines whether the current thread is unwinding because of panic.
460460///
461+ /// A common use of this feature is to poison shared resources when writing
462+ /// unsafe code, by checking `panicking` when the `drop` is called.
463+ ///
464+ /// This is usually not needed when writing safe code, as [`Mutex`es][Mutex]
465+ /// already poison themselves when a thread panics while holding the lock.
466+ ///
467+ /// This can also be used in multithreaded applications, in order to send a
468+ /// message to other threads warning that a thread has panicked (e.g. for
469+ /// monitoring purposes).
470+ ///
461471/// # Examples
462472///
463473/// ```should_panic
@@ -486,6 +496,8 @@ pub fn yield_now() {
486496/// panic!()
487497/// }
488498/// ```
499+ ///
500+ /// [Mutex]: ../../std/sync/struct.Mutex.html
489501#[ inline]
490502#[ stable( feature = "rust1" , since = "1.0.0" ) ]
491503pub fn panicking ( ) -> bool {
You can’t perform that action at this time.
0 commit comments