pub struct Lease<T: RefCnt> { /* private fields */ }
Expand description
A temporary storage of the pointer.
This, unlike Guard
, does not block any write operations and is usually
faster than loading the full Arc
. However, this holds only if each thread keeps only small
number of Lease
s around and if too many are held, the following ones will just fall back to
creating the Arc
internally.
Implementations
sourceimpl<T: RefCnt> Lease<T>
impl<T: RefCnt> Lease<T>
sourcepub fn into_upgrade(lease: Self) -> T
pub fn into_upgrade(lease: Self) -> T
A consuming version of upgrade
.
This is a bit faster in certain situations, but consumes the lease.
sourceimpl<T: NonNull> Lease<Option<T>>
impl<T: NonNull> Lease<Option<T>>
sourcepub fn unwrap(self) -> Lease<T>
pub fn unwrap(self) -> Lease<T>
Asserts the lease contains non-NULL content and gets direct access to it.
This is very much like Option::unwrap
.
Panics
If the lease contains a NULL pointer.
sourcepub fn into_option(self) -> Option<Lease<T>>
pub fn into_option(self) -> Option<Lease<T>>
Transposes the Lease<Option<RefCnt>>
into Option<Lease<RefCnt>>
.
Examples
let shared = ArcSwapOption::from_pointee(42);
if let Some(ptr) = shared.lease().into_option() {
println!("It is {}", ptr);
} else {
println!("Nothing present");
}
Trait Implementations
impl<T> Send for Lease<T> where
T: RefCnt + Send + Sync,
T::Base: Send + Sync,
impl<T> Sync for Lease<T> where
T: RefCnt + Send + Sync,
T::Base: Send + Sync,
Auto Trait Implementations
impl<T> RefUnwindSafe for Lease<T> where
T: RefUnwindSafe,
<T as RefCnt>::Base: RefUnwindSafe,
impl<T> Unpin for Lease<T> where
T: Unpin,
impl<T> UnwindSafe for Lease<T> where
T: UnwindSafe,
<T as RefCnt>::Base: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more