pub trait MutexExt<'a, T, R>: Sealedwhere
Self: 'a,{
// Required method
fn lock_py_attached(&'a self, py: Python<'_>) -> R;
}
Expand description
Extension trait for std::sync::Mutex
which helps avoid deadlocks between
the Python interpreter and acquiring the Mutex
.
Required Methods§
Sourcefn lock_py_attached(&'a self, py: Python<'_>) -> R
fn lock_py_attached(&'a self, py: Python<'_>) -> R
Lock this Mutex
in a manner that cannot deadlock with the Python interpreter.
Before attempting to lock the mutex, this function detaches from the
Python runtime. When the lock is acquired, it re-attaches to the Python
runtime before returning the LockResult
. This avoids deadlocks between
the GIL and other global synchronization events triggered by the Python
interpreter.
Implementations on Foreign Types§
Source§impl<'a, R, T> MutexExt<'a, T, ArcMutexGuard<R, T>> for Arc<Mutex<R, T>>where
R: RawMutex,
Self: 'a,
Available on crate feature arc_lock
only.
impl<'a, R, T> MutexExt<'a, T, ArcMutexGuard<R, T>> for Arc<Mutex<R, T>>where
R: RawMutex,
Self: 'a,
Available on crate feature
arc_lock
only.fn lock_py_attached(&self, _py: Python<'_>) -> ArcMutexGuard<R, T>
Source§impl<'a, R: RawMutex, T> MutexExt<'a, T, MutexGuard<'a, R, T>> for Mutex<R, T>
Available on crate feature lock_api
only.
impl<'a, R: RawMutex, T> MutexExt<'a, T, MutexGuard<'a, R, T>> for Mutex<R, T>
Available on crate feature
lock_api
only.