pub struct CacheLocker {
state: RefCell<CacheState>,
}
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.
Fields§
§state: RefCell<CacheState>
The state of the locker.
CacheLocker
uses interior mutability because it is stuffed inside
GlobalContext
, which does not allow mutation.
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,
DownloadExclusive
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 120 bytes