Trait RwLockExt
pub trait RwLockExt<T>: Sealed {
type ReadLockResult<'a>
where Self: 'a;
type WriteLockResult<'a>
where Self: 'a;
// Required methods
fn read_py_attached(&self, py: Python<'_>) -> Self::ReadLockResult<'_>;
fn write_py_attached(&self, py: Python<'_>) -> Self::WriteLockResult<'_>;
}tls only.Expand description
Extension trait for std::sync::RwLock which helps avoid deadlocks between
the Python interpreter and acquiring the RwLock.
Required Associated Types§
type ReadLockResult<'a>
where
Self: 'a
type ReadLockResult<'a> where Self: 'a
The result type returned by the read_py_attached method.
type WriteLockResult<'a>
where
Self: 'a
type WriteLockResult<'a> where Self: 'a
The result type returned by the write_py_attached method.
Required Methods§
fn read_py_attached(&self, py: Python<'_>) -> Self::ReadLockResult<'_>
fn read_py_attached(&self, py: Python<'_>) -> Self::ReadLockResult<'_>
Lock this RwLock for reading in a manner that cannot deadlock with
the Python interpreter.
Before attempting to lock the rwlock, this function detaches from the
Python runtime. When the lock is acquired, it re-attaches to the Python
runtime before returning the ReadLockResult. This avoids deadlocks between
the GIL and other global synchronization events triggered by the Python
interpreter.
fn write_py_attached(&self, py: Python<'_>) -> Self::WriteLockResult<'_>
fn write_py_attached(&self, py: Python<'_>) -> Self::WriteLockResult<'_>
Lock this RwLock for writing in a manner that cannot deadlock with
the Python interpreter.
Before attempting to lock the rwlock, this function detaches from the
Python runtime. When the lock is acquired, it re-attaches to the Python
runtime before returning the WriteLockResult. This avoids deadlocks between
the GIL and other global synchronization events triggered by the Python
interpreter.
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.