[−][src]Trait kul::drop::RcLikeAtomicCounts
Allows generically working with Datum
reference types that wrap Rc
-like
types that can supply both strong and weak reference counts atomically.
Currently, this is only Rc
, but hopefully in the future Arc
can be
included as well if it can provide the ability to get both counts
atomically. This could also be used for other, non-standard, types that
meet the requirements.
Required methods
fn counts(this: &Self) -> (usize, usize)
Atomically gets the number of strong and weak pointers to the underlying
value. I.e. gets a snapshot of the state of both the strong and weak
counts at the same logical instant. In particular, when strong=1 and
weak=0 this means either count cannot change after this function returns
except via use of the only strong reference, and if you control that
strong reference and do not change the counts, then you can depend on
being able to get mutable access (e.g. via get_mut
) to the underlying
value, guaranteed.
Provided methods
fn try_replace_optim(
this: &mut Self,
val: Self::Target
) -> Result<Self::Target, Self::Target>
this: &mut Self,
val: Self::Target
) -> Result<Self::Target, Self::Target>
Optimized implementation of Algo1DatumRef::try_replace
for generic
Rc
-like types that can supply both strong and weak reference counts
atomically. The default implementation uses DerefTryMut
when possible
to avoid the heap allocation and unwrapping that the basic default
RcLike::try_replace
does.