pub trait AsyncUnlockable {
// Required method
fn unlocked_async<'life0, 'async_trait, F, U>(
s: &'life0 mut Self,
f: F,
) -> Pin<Box<dyn Future<Output = U> + 'async_trait>>
where F: AsyncFnOnce() -> U + 'async_trait,
U: 'async_trait,
Self: 'async_trait,
'life0: 'async_trait;
}Expand description
A trait for lock guards that can be temporarily unlocked asynchronously. This is useful for performing async operations while holding a lock, without causing deadlocks or holding the lock for an extended period.
Required Methods§
Sourcefn unlocked_async<'life0, 'async_trait, F, U>(
s: &'life0 mut Self,
f: F,
) -> Pin<Box<dyn Future<Output = U> + 'async_trait>>where
F: AsyncFnOnce() -> U + 'async_trait,
U: 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
fn unlocked_async<'life0, 'async_trait, F, U>(
s: &'life0 mut Self,
f: F,
) -> Pin<Box<dyn Future<Output = U> + 'async_trait>>where
F: AsyncFnOnce() -> U + 'async_trait,
U: 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
Temporarily unlocks the guard s, executes the async function f, and then
re-locks the guard.
The lock is guaranteed to be re-acquired before this function returns.
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.