pub struct RefCount { /* private fields */ }Expand description
Reference count using state layout with LEAKED and IMMORTAL support.
State layout (usize): 64-bit: [destructed] [published] [leaked] [immortal] [60 bits: strong_count] 32-bit: [destructed] [published] [leaked] [immortal] [28 bits: strong_count]
See [IMMORTAL] for what the immortal bit promises.
Implementations§
Source§impl RefCount
impl RefCount
Sourcepub fn is_immortal(&self) -> bool
pub fn is_immortal(&self) -> bool
Whether this object lives for the whole process.
A plain relaxed load: the bit is sticky and is set before the object is shared, so no reader can observe it flipping.
pub fn inc_by(&self, n: usize)
Sourcepub fn leak(&self)
pub fn leak(&self)
Mark this object as leaked (interned). It will never be deallocated.
This also makes the object immortal, and RefCount::dec depends on
that: leaked and immortal are separate answers — is_leaked means “the
string pool owns this copy” and is what pointer-equality key lookups
read — but every leaked object is immortal, so dec can decide both
from the immortal bit alone.
Sourcepub fn make_immortal(&self)
pub fn make_immortal(&self)
Make this object immortal: every later inc/dec becomes a branch and
the object is never deallocated. See [IMMORTAL] for the invariant.
Idempotent, and safe to call on an object that is already interned — the other flags are preserved.
Sourcepub fn mark_published(&self)
pub fn mark_published(&self)
Mark the object as published to a lock-free cache (sticky).
pub fn is_published(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for RefCount
impl !RefUnwindSafe for RefCount
impl !Sync for RefCount
impl Send for RefCount
impl Unpin for RefCount
impl UnsafeUnpin for RefCount
impl UnwindSafe for RefCount
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> ErasedDestructor for Twhere
T: 'static,
Source§impl<T, U> ImaginaryInto<U> for Twhere
U: ImaginaryFrom<T>,
impl<T, U> ImaginaryInto<U> for Twhere
U: ImaginaryFrom<T>,
fn imaginary_into(self) -> U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more