Struct OrchestratorMutex

Source
pub struct OrchestratorMutex<T> { /* private fields */ }

Implementations§

Source§

impl<T> OrchestratorMutex<T>

Source

pub fn new(value: T) -> Self

Source

pub fn add_locker(&self) -> (Granter<T>, MutexLocker<T>)

Source

pub async fn acquire(&self) -> MutexGuard<'_, T>

Directly acquire the underlying lock.

Source

pub fn try_acquire(&self) -> Result<MutexGuard<'_, T>, TryLockError>

Attempt to acquire the underlying lock, failing if the lock is already held.

Source

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.

Auto Trait Implementations§

§

impl<T> Freeze for OrchestratorMutex<T>

§

impl<T> !RefUnwindSafe for OrchestratorMutex<T>

§

impl<T> Send for OrchestratorMutex<T>
where T: Send,

§

impl<T> Sync for OrchestratorMutex<T>
where T: Send,

§

impl<T> Unpin for OrchestratorMutex<T>

§

impl<T> !UnwindSafe for OrchestratorMutex<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.