Struct PanicMonitor

Source
pub struct PanicMonitor { /* private fields */ }
Expand description

A list of all threads which have panicked, with the ability to notify interested parties when this list is updated.

Implementations§

Source§

impl PanicMonitor

Source

pub fn new() -> PanicMonitor

Create a new PanicMonitor.

Call this inside a lazy_static block. You must call init after this.

Source

pub fn init(&'static self)

Initialise the PanicMonitor.

Call this method as early as you can: a thread which panics before the PanicMonitor is initialised will not trigger wake-ups. Calling init multiple times is relatively harmless.

Source

pub fn wait(&self, watch_list: &[ThreadId]) -> Vec<Thread>

Block the current thread until one of the watched threads panics. The returned vector is always non-empty.

Note that this function returns as soon as one or more of the threads on the watch list has panicked. This means that if you specify a thread which has already panicked, this function will return immediately. Think of it as level-triggered, not edge-triggered.

Source

pub fn wait_timeout( &self, watch_list: &[ThreadId], dur: Duration, ) -> Vec<Thread>

Block the current thread until one of the watched threads panic, or the timeout expires. The returned vector is empty if and only if the timeout expired.

See wait for more information.

Source

pub fn check(&self, watch_list: &[ThreadId]) -> Vec<Thread>

Check if any of the specified threads have panicked. This function may block, but only very briefly. The returned vector may be empty.

See wait for more information.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.