Struct cargo::util::cache_lock::CacheLocker
source · pub struct CacheLocker { /* private fields */ }
Expand description
A locker that can be used to acquire locks.
See the crate::util::cache_lock
module documentation for an overview
of how cache locking works.
Implementations§
source§impl CacheLocker
impl CacheLocker
sourcepub fn new() -> CacheLocker
pub fn new() -> CacheLocker
Creates a new CacheLocker
.
sourcepub fn lock(
&self,
gctx: &GlobalContext,
mode: CacheLockMode
) -> CargoResult<CacheLock<'_>>
pub fn lock( &self, gctx: &GlobalContext, mode: CacheLockMode ) -> CargoResult<CacheLock<'_>>
Acquires a lock with the given mode, possibly blocking if another cargo is holding the lock.
sourcepub fn try_lock(
&self,
gctx: &GlobalContext,
mode: CacheLockMode
) -> CargoResult<Option<CacheLock<'_>>>
pub fn try_lock( &self, gctx: &GlobalContext, mode: CacheLockMode ) -> CargoResult<Option<CacheLock<'_>>>
Acquires a lock with the given mode, returning None
if another cargo
is holding the lock.
sourcepub fn is_locked(&self, mode: CacheLockMode) -> bool
pub fn is_locked(&self, mode: CacheLockMode) -> bool
Returns whether or not a lock is held for the given mode in this locker.
This does not tell you whether or not it is locked in some other locker (such as in another process).
Note that Shared
will return true if a MutateExclusive
lock is
held, since MutateExclusive
is just an upgraded Shared
. Likewise,
DownlaodExclusive
will return true if a MutateExclusive
lock is
held since they overlap.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for CacheLocker
impl !RefUnwindSafe for CacheLocker
impl Send for CacheLocker
impl !Sync for CacheLocker
impl Unpin for CacheLocker
impl UnwindSafe for CacheLocker
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more