pub struct LockedAt<'a, L>(/* private fields */);Expand description
Empty type that enforces lock acquisition ordering.
This type wraps a lock level L representing the level of the “currently
held” lock, and provides methods for accessing state for other lock levels.
For a given L, the methods on LockedAt<'_, L> will allow accessing state
for a lock level M if M: LockAfter<L>.
The with_ methods on this type will (if they don’t return an error),
produce two values: a new LockedAt instance and an accessor for locked
state. Both values will exclusively borrow the original LockedAt
instance, preventing its use, until the new values go out of scope.
Implementations§
Source§impl<L> LockedAt<'_, L>
impl<L> LockedAt<'_, L>
Sourcepub fn with_lock<'a, NewLock>(
&'a mut self,
t: &'a NewLock::Mutex,
) -> Result<(LockedAt<'a, NewLock>, <NewLock::Mutex as MutexLock>::Guard<'a>), <NewLock::Mutex as MutexLock>::Error<'a>>where
NewLock: MutexLockLevel,
L: LockBefore<NewLock>,
pub fn with_lock<'a, NewLock>(
&'a mut self,
t: &'a NewLock::Mutex,
) -> Result<(LockedAt<'a, NewLock>, <NewLock::Mutex as MutexLock>::Guard<'a>), <NewLock::Mutex as MutexLock>::Error<'a>>where
NewLock: MutexLockLevel,
L: LockBefore<NewLock>,
Attempts to acquire a lock on NewLock state.
Assuming NewLock is a lock level that can be acquired after L, this
method provides access to state held in the MutexLock type
NewLock::Mutex. If the lock acquisition fails, an error will be
returned. Otherwise, this method returns a new LockedAt along with an
accessor for the held state.
If no further LockedAt calls need to be made after this one, consider
using LockedAt::lock instead.
Sourcepub fn with_read_lock<'a, NewLock>(
&'a mut self,
t: &'a NewLock::RwLock,
) -> Result<(LockedAt<'a, NewLock>, <NewLock::RwLock as RwLock>::ReadGuard<'a>), <NewLock::RwLock as RwLock>::ReadError<'a>>where
NewLock: RwLockLevel,
L: LockBefore<NewLock>,
pub fn with_read_lock<'a, NewLock>(
&'a mut self,
t: &'a NewLock::RwLock,
) -> Result<(LockedAt<'a, NewLock>, <NewLock::RwLock as RwLock>::ReadGuard<'a>), <NewLock::RwLock as RwLock>::ReadError<'a>>where
NewLock: RwLockLevel,
L: LockBefore<NewLock>,
Attempts to acquire a shared lock on NewLock state.
Assuming NewLock is a lock level that can be acquired after L, this
method provides access to state held in the ReadWrite type
NewLock::RwLock. If the lock acquisition fails, an error will be
returned. Otherwise, this method returns a new LockedAt along with a
read-only accessor for the held state.
If no further LockedAt calls need to be made after this one, consider
using LockedAt::read_lock instead.
Sourcepub fn with_write_lock<'a, NewLock>(
&'a mut self,
t: &'a NewLock::RwLock,
) -> Result<(LockedAt<'a, NewLock>, <NewLock::RwLock as RwLock>::WriteGuard<'a>), <NewLock::RwLock as RwLock>::WriteError<'a>>where
NewLock: RwLockLevel,
L: LockBefore<NewLock>,
pub fn with_write_lock<'a, NewLock>(
&'a mut self,
t: &'a NewLock::RwLock,
) -> Result<(LockedAt<'a, NewLock>, <NewLock::RwLock as RwLock>::WriteGuard<'a>), <NewLock::RwLock as RwLock>::WriteError<'a>>where
NewLock: RwLockLevel,
L: LockBefore<NewLock>,
Attempts to acquire an exclusive lock on NewLock state.
Assuming NewLock is a lock level that can be acquired after L, this
method provides access to state held in the ReadWrite type T. If the
lock acquisition fails, an error will be returned. Otherwise, this
method returns a new LockedAt along with a read/write accessor for the
held state.
If no further LockedAt calls need to be made after this one, consider
using LockedAt::write_lock instead.
Source§impl<L> LockedAt<'_, L>
impl<L> LockedAt<'_, L>
Sourcepub fn lock<'a, NewLock>(
&'a mut self,
t: &'a NewLock::Mutex,
) -> Result<<NewLock::Mutex as MutexLock>::Guard<'a>, <NewLock::Mutex as MutexLock>::Error<'a>>where
NewLock: 'a + MutexLockLevel,
L: LockBefore<NewLock>,
pub fn lock<'a, NewLock>(
&'a mut self,
t: &'a NewLock::Mutex,
) -> Result<<NewLock::Mutex as MutexLock>::Guard<'a>, <NewLock::Mutex as MutexLock>::Error<'a>>where
NewLock: 'a + MutexLockLevel,
L: LockBefore<NewLock>,
Provides access to a MutexLock’s state.
Sourcepub fn read_lock<'a, NewLock>(
&'a mut self,
t: &'a NewLock::RwLock,
) -> Result<<NewLock::RwLock as RwLock>::ReadGuard<'a>, <NewLock::RwLock as RwLock>::ReadError<'a>>where
NewLock: RwLockLevel + 'a,
L: LockBefore<NewLock>,
pub fn read_lock<'a, NewLock>(
&'a mut self,
t: &'a NewLock::RwLock,
) -> Result<<NewLock::RwLock as RwLock>::ReadGuard<'a>, <NewLock::RwLock as RwLock>::ReadError<'a>>where
NewLock: RwLockLevel + 'a,
L: LockBefore<NewLock>,
Provides read access to a RwLock’s state.
Sourcepub fn write_lock<'a, NewLock>(
&'a mut self,
t: &'a NewLock::RwLock,
) -> Result<<NewLock::RwLock as RwLock>::WriteGuard<'a>, <NewLock::RwLock as RwLock>::WriteError<'a>>where
NewLock: RwLockLevel + 'a,
L: LockBefore<NewLock>,
pub fn write_lock<'a, NewLock>(
&'a mut self,
t: &'a NewLock::RwLock,
) -> Result<<NewLock::RwLock as RwLock>::WriteGuard<'a>, <NewLock::RwLock as RwLock>::WriteError<'a>>where
NewLock: RwLockLevel + 'a,
L: LockBefore<NewLock>,
Provides read/write access to a RwLock’s state.
Source§impl<L> LockedAt<'_, L>
impl<L> LockedAt<'_, L>
Sourcepub async fn wait_for_lock<'a, NewLock>(
&'a mut self,
t: &'a NewLock::Mutex,
) -> (LockedAt<'a, NewLock>, <NewLock::Mutex as AsyncMutexLock>::Guard<'a>)where
NewLock: AsyncMutexLockLevel + 'a,
L: LockBefore<NewLock>,
pub async fn wait_for_lock<'a, NewLock>(
&'a mut self,
t: &'a NewLock::Mutex,
) -> (LockedAt<'a, NewLock>, <NewLock::Mutex as AsyncMutexLock>::Guard<'a>)where
NewLock: AsyncMutexLockLevel + 'a,
L: LockBefore<NewLock>,
Asynchronously acquires a lock on NewLock state.
Assuming NewLock is a lock level that can be acquired after L, this
method provides access to state held in the AsyncMutexLock type
NewLock::Mutex, yielding the current task until the lock can be
acquired. Once the state is locked, returns a guard for accessing it
and a new LockedAt instance that can be used to acquire additional
locks.
If no further LockedAt calls need to be made after this one, consider
using LockedAt::wait_lock instead.
Sourcepub async fn wait_for_read<'a, NewLock>(
&'a mut self,
t: &'a NewLock::RwLock,
) -> (LockedAt<'a, NewLock>, <NewLock::RwLock as AsyncRwLock>::ReadGuard<'a>)where
NewLock: AsyncRwLockLevel + 'a,
L: LockBefore<NewLock>,
pub async fn wait_for_read<'a, NewLock>(
&'a mut self,
t: &'a NewLock::RwLock,
) -> (LockedAt<'a, NewLock>, <NewLock::RwLock as AsyncRwLock>::ReadGuard<'a>)where
NewLock: AsyncRwLockLevel + 'a,
L: LockBefore<NewLock>,
Asynchronously acquires a shared lock on NewLock state.
Assuming NewLock is a lock level that can be acquired after L, this
method provides access to state held in the ReadWrite type T.
This method will yield the current task until the lock can be acquired.
Once the state is locked, this method returns a guard for accessing it
and a new LockedAt instance that can be used to acquire additional
locks.
If no further LockedAt calls need to be made after this one, consider
using LockedAt::wait_read instead.
Sourcepub async fn wait_for_write<'a, NewLock>(
&'a mut self,
t: &'a NewLock::RwLock,
) -> (LockedAt<'a, NewLock>, <NewLock::RwLock as AsyncRwLock>::WriteGuard<'a>)where
NewLock: AsyncRwLockLevel + 'a,
L: LockBefore<NewLock>,
pub async fn wait_for_write<'a, NewLock>(
&'a mut self,
t: &'a NewLock::RwLock,
) -> (LockedAt<'a, NewLock>, <NewLock::RwLock as AsyncRwLock>::WriteGuard<'a>)where
NewLock: AsyncRwLockLevel + 'a,
L: LockBefore<NewLock>,
Attempts to acquire an exclusive lock on NewLock state.
Assuming NewLock is a lock level that can be acquired after L, this
method provides access to state held in the ReadWrite type T. If the
lock acquisition fails, an error will be returned. Otherwise, this
method returns a new LockedAt along with a read/write accessor for the
held state.
If no further LockedAt calls need to be made after this one, consider
using LockedAt::write_lock instead.
Source§impl<L> LockedAt<'_, L>
impl<L> LockedAt<'_, L>
Sourcepub async fn wait_lock<'a, NewLock>(
&'a mut self,
t: &'a NewLock::Mutex,
) -> <NewLock::Mutex as AsyncMutexLock>::Guard<'a>where
NewLock: 'a + AsyncMutexLockLevel,
L: LockBefore<NewLock>,
pub async fn wait_lock<'a, NewLock>(
&'a mut self,
t: &'a NewLock::Mutex,
) -> <NewLock::Mutex as AsyncMutexLock>::Guard<'a>where
NewLock: 'a + AsyncMutexLockLevel,
L: LockBefore<NewLock>,
Asynchronously provides access to an AsyncMutexLock’s state.
Sourcepub async fn wait_read<'a, NewLock>(
&'a mut self,
t: &'a NewLock::RwLock,
) -> <NewLock::RwLock as AsyncRwLock>::ReadGuard<'a>where
NewLock: AsyncRwLockLevel + 'a,
L: LockBefore<NewLock>,
pub async fn wait_read<'a, NewLock>(
&'a mut self,
t: &'a NewLock::RwLock,
) -> <NewLock::RwLock as AsyncRwLock>::ReadGuard<'a>where
NewLock: AsyncRwLockLevel + 'a,
L: LockBefore<NewLock>,
Asynchronously provides read access to an AsyncRwLock’s state.
Sourcepub async fn wait_write<'a, NewLock>(
&'a mut self,
t: &'a NewLock::RwLock,
) -> <NewLock::RwLock as AsyncRwLock>::WriteGuard<'a>where
NewLock: AsyncRwLockLevel + 'a,
L: LockBefore<NewLock>,
pub async fn wait_write<'a, NewLock>(
&'a mut self,
t: &'a NewLock::RwLock,
) -> <NewLock::RwLock as AsyncRwLock>::WriteGuard<'a>where
NewLock: AsyncRwLockLevel + 'a,
L: LockBefore<NewLock>,
Asynchronously provides read/write access to an AsyncRwLock’s state.