Type Definition arc_swap::ArcSwap [−][src]
type ArcSwap<T> = ArcSwapAny<Arc<T>>;
An atomic storage for Arc
.
This is a type alias only. Most of its methods are described on
ArcSwapAny
.
Methods
impl<T> ArcSwap<T>
[src]
impl<T> ArcSwap<T>
pub fn rcu_unwrap<R, F>(&self, f: F) -> T where
F: FnMut(&T) -> R,
R: Into<Arc<T>>,
[src]
pub fn rcu_unwrap<R, F>(&self, f: F) -> T where
F: FnMut(&T) -> R,
R: Into<Arc<T>>,
An rcu
which waits to be the sole owner of the original value and unwraps
it.
This one works the same way as the rcu
method, but works on the inner type
instead of Arc
. After replacing the original, it waits until there are no other owners of
the arc and unwraps it.
Possible use case might be an RCU with a structure that is rather slow to drop ‒ if it was left to random reader (the last one to hold the old value), it could cause a timeout or jitter in a query time. With this, the deallocation is done in the updater thread, therefore outside of the hot path.
Warning
Note that if you store a copy of the Arc
somewhere except the ArcSwap
itself for
extended period of time, this'll busy-wait the whole time. Unless you need the assurance
the Arc
is deconstructed here, prefer rcu
.