pub struct RcuStack<T, F = RcuDefaultFlavor> { /* private fields */ }Expand description
Defines a RCU wait-free stack.
This stack supports multiple concurrents readers and writers. It is guaranteed to never block on a call.
§Limitations
§Mutable References
Because there might always be readers borrowing a node’s data, it is impossible to get a mutable references to the data inside the stack. You should design the type stored in the stack with interior mutabillity that can be shared between threads.
§List Length
Because a writer might concurrently modify the stack, the amount of node might change
at any moment. To prevent user error (e.g. allocate an array for each node), there is
no .len() method.
§Safety
It is safe to send an Arc<RcuStack<T>> to a non-registered RCU thread. A non-registered
thread may drop an RcuStack<T> without calling any RCU primitives since lifetime rules
prevent any other thread from accessing a RCU reference.
Implementations§
Source§impl<T, F> RcuStack<T, F>where
F: RcuFlavor,
impl<T, F> RcuStack<T, F>where
F: RcuFlavor,
Sourcepub fn pop<G>(&self, guard: &G) -> Option<Ref<T, F>>
pub fn pop<G>(&self, guard: &G) -> Option<Ref<T, F>>
Removes an element from the top of the stack.
Sourcepub fn peek<'me, 'guard, G>(&'me self, _guard: &'guard G) -> Option<&'guard T>where
G: RcuGuard<Flavor = F>,
'me: 'guard,
pub fn peek<'me, 'guard, G>(&'me self, _guard: &'guard G) -> Option<&'guard T>where
G: RcuGuard<Flavor = F>,
'me: 'guard,
Returns a reference to the element on top of the stack.