[−][src]Struct arc_swap::Guard
A short-term proxy object from peek.
This allows for upgrading to a full smart pointer and borrowing of the value inside. It also
dereferences to the actual pointed to type if the smart pointer guarantees not to contain NULL
values (eg. on Arc, but not on Option<Arc>).
Warning
Do not store or keep around for a long time, as this prevents all the writer methods from completing on all the swap objects in the whole program from completing.
Methods
impl<'a, T: RefCnt, S: LockStorage> Guard<'a, T, S>[src]
pub fn upgrade(guard: &Self) -> T[src]
Upgrades the guard to a real Arc.
This shares the reference count with all the Arc inside the corresponding ArcSwap. Use
this if you need to hold the object for longer periods of time.
See peek for details.
Note that this is associated function (so it doesn't collide with the thing pointed to):
Examples
let a = ArcSwap::from(Arc::new(42)); let mut ptr = None; { // limit the scope where the guard lives let guard = a.peek(); if *guard > 40 { ptr = Some(Guard::upgrade(&guard)); } }
pub fn lease(guard: &Self) -> Lease<T>[src]
Use upgrade instead
Upgrades the guard to a Lease.
This is preserved here for backwards compatibility. Use upgrade
instead (it has the same cost).
pub fn get_ref<'g>(guard: &'g Self) -> Option<&'g T::Base>[src]
Gets a reference to the value inside.
This is returned as Option even for pointers that can't return Null, to have a common
interface. The non-null ones also implement the Deref trait, so they can more easily be
used as that.
Trait Implementations
impl<'a, T: RefCnt> AsRaw<<T as RefCnt>::Base> for Guard<'a, T>[src]
impl<'a, T, S> Sync for Guard<'a, T, S> where
T: RefCnt + Send + Sync,
S: LockStorage,
T::Base: Send + Sync, [src]
T: RefCnt + Send + Sync,
S: LockStorage,
T::Base: Send + Sync,
impl<'a, T, S> Send for Guard<'a, T, S> where
T: RefCnt + Send + Sync,
S: LockStorage,
T::Base: Send + Sync, [src]
T: RefCnt + Send + Sync,
S: LockStorage,
T::Base: Send + Sync,
impl<'a, T: RefCnt, S: LockStorage> Drop for Guard<'a, T, S>[src]
impl<'a, T: NonNull, S: LockStorage> Deref for Guard<'a, T, S>[src]
Blanket Implementations
impl<T> From for T[src]
impl<T, U> Into for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T> Borrow for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T, U> TryInto for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,