pub struct OrchestratorMutex<T> { /* private fields */ }Implementations§
Source§impl<T> OrchestratorMutex<T>
impl<T> OrchestratorMutex<T>
pub fn new(value: T) -> Self
pub fn add_locker(&self) -> (Granter<T>, MutexLocker<T>)
Sourcepub async fn acquire(&self) -> MutexGuard<'_, T>
pub async fn acquire(&self) -> MutexGuard<'_, T>
Directly acquire the underlying lock.
Sourcepub fn try_acquire(&self) -> Result<MutexGuard<'_, T>, TryLockError>
pub fn try_acquire(&self) -> Result<MutexGuard<'_, T>, TryLockError>
Attempt to acquire the underlying lock, failing if the lock is already held.
Sourcepub async fn grant_access(
&self,
granter: &mut Granter<T>,
) -> Result<impl Future<Output = MutexGuard<'_, T>>, GrantError>
pub async fn grant_access( &self, granter: &mut Granter<T>, ) -> Result<impl Future<Output = MutexGuard<'_, T>>, GrantError>
Grants lock access to the MutexLocker corresponding to the provided Granter.
This function returns Ok once the corresponding MutexLocker has called acquire (or Err if the MutexLocker has been dropped). The Ok variant contains a future which waits for the MutexGuard to be dropped and then re-acquires the mutex so the caller can see what changes were made.
If the future in the Ok variant is dropped, the next call to grant_access will have to wait for the current MutexGuard to be dropped before it can grant access to the next MutexLocker. If this is called multiple times in parallel, the order in which the MutexLockers are granted access is unspecified.
§Panics
Panics if granter was created from a different OrchestratorMutex.