Skip to main content

SafeLock

Trait SafeLock 

Source
pub trait SafeLock {
    type Output<'a>
       where Self: 'a;

    const TIMEOUT: Duration = _;

    // Required method
    fn safe_lock(&self) -> Self::Output<'_>;
}
Expand description

Trait for lockable objects that can panic if they take too long to lock. Panicking is preferable over freezing.

Provided Associated Constants§

Required Associated Types§

Source

type Output<'a> where Self: 'a

Required Methods§

Source

fn safe_lock(&self) -> Self::Output<'_>

Attempt to lock the object, with a limit on how long locking may block for, panicking if the time limit is exceeded. It panics instead of freezing.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T> SafeLock for Mutex<T>
where T: ?Sized,

Source§

type Output<'a> = Result<MutexGuard<'a, T>, PoisonError<MutexGuard<'a, T>>> where T: 'a

Source§

fn safe_lock(&self) -> <Mutex<T> as SafeLock>::Output<'_>

Implementors§

Source§

impl<T> SafeLock for fyrox_impl::core::parking_lot::lock_api::Mutex<RawMutex, T>
where T: ?Sized,

Source§

type Output<'a> = MutexGuard<'a, RawMutex, T> where T: 'a