Struct PoisonError
struct PoisonError<T> { ... }
A type of error which can be returned whenever a lock is acquired.
Both Mutexes and RwLocks are poisoned whenever a thread fails while the lock
is held. The precise semantics for when a lock is poisoned is documented on
each lock. For a lock in the poisoned state, unless the state is cleared manually,
all future acquisitions will return this error.
Examples
use ;
use thread;
let mutex = new;
// poison the mutex
let c_mutex = clone;
let _ = spawn.join;
match mutex.lock ;
Implementations
impl<T> PoisonError<T>
fn new(data: T) -> PoisonError<T>Creates a
PoisonError.This is generally created by methods like
Mutex::lockorRwLock::read.This method may panic if std was built with
panic="abort".fn into_inner(self: Self) -> TConsumes this error indicating that a lock is poisoned, returning the associated data.
Examples
use HashSet; use ; use thread; let mutex = new; // poison the mutex let c_mutex = clone; let _ = spawn.join; let p_err = mutex.lock.unwrap_err; let data = p_err.into_inner; println!;fn get_ref(self: &Self) -> &TReaches into this error indicating that a lock is poisoned, returning a reference to the associated data.
fn get_mut(self: &mut Self) -> &mut TReaches into this error indicating that a lock is poisoned, returning a mutable reference to the associated data.
impl<T> Any for PoisonError<T>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for PoisonError<T>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for PoisonError<T>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> Debug for PoisonError<T>
fn fmt(self: &Self, f: &mut fmt::Formatter<'_>) -> fmt::Result
impl<T> Display for PoisonError<T>
fn fmt(self: &Self, f: &mut fmt::Formatter<'_>) -> fmt::Result
impl<T> Error for PoisonError<T>
impl<T> Freeze for PoisonError<T>
impl<T> From for PoisonError<T>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> RefUnwindSafe for PoisonError<T>
impl<T> Send for PoisonError<T>
impl<T> Sync for PoisonError<T>
impl<T> ToString for PoisonError<T>
fn to_string(self: &Self) -> String
impl<T> Unpin for PoisonError<T>
impl<T> UnwindSafe for PoisonError<T>
impl<T, U> Into for PoisonError<T>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for PoisonError<T>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for PoisonError<T>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>