Struct RcuHashMap

Source
pub struct RcuHashMap<K, V, F = RcuDefaultFlavor>(/* private fields */)
where
    K: Send + 'static,
    V: Send + 'static,
    F: RcuFlavor + 'static;
Expand description

Defines a RCU lock-free hashmap.

This hashmap 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.

§Safety

It is safe to send an Arc<RcuHashMap<T>> to a non-registered RCU thread. A non-registered thread may drop an RcuHashMap<T> without calling any RCU primitives since lifetime rules prevent any other thread from accessing an RCU reference.

Implementations§

Source§

impl<K, V, F> RcuHashMap<K, V, F>
where K: Send, V: Send, F: RcuFlavor,

Source

pub fn new() -> Result<Arc<Self>>

Creates a new RCU hashmap.

Source

pub fn insert<G>(&self, key: K, value: V, guard: &G) -> Option<Ref<K, V, F>>
where K: Send + Eq + Hash, V: Send, G: RcuGuard<Flavor = F>,

Inserts a key-value pair in the hashmap.

If the hashmap did not have this key present, None is returned.

Source

pub fn contains<G>(&self, key: &K, guard: &G) -> bool
where K: Eq + Hash, G: RcuGuard<Flavor = F>,

Returns true if the hashmap contains a value for the specified key.

Source

pub fn get<'me, 'guard, G>( &'me self, key: &K, _guard: &'guard G, ) -> Option<&'guard V>
where K: Eq + Hash, G: RcuGuard<Flavor = F>, 'me: 'guard,

Returns a reference to the value corresponding to the key.

Source

pub fn remove<G>(&self, key: &K, guard: &G) -> Option<Ref<K, V, F>>
where K: Send + Eq + Hash, V: Send, G: RcuGuard<Flavor = F>,

Removes a key from the hashmap, returning the key-value pair if successful.

Source

pub fn iter<'me, 'guard, G>( &'me self, guard: &'guard G, ) -> Iter<'guard, K, V, F>
where G: RcuGuard<Flavor = F>, 'me: 'guard,

Returns an iterator visiting all key-value pairs in arbitrary order.

Trait Implementations§

Source§

impl<K, V, F> Drop for RcuHashMap<K, V, F>
where K: Send + 'static, V: Send + 'static, F: RcuFlavor + 'static,

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<K, V, F> Freeze for RcuHashMap<K, V, F>

§

impl<K, V, F> RefUnwindSafe for RcuHashMap<K, V, F>

§

impl<K, V, F> Send for RcuHashMap<K, V, F>

§

impl<K, V, F> Sync for RcuHashMap<K, V, F>
where K: Sync, V: Sync,

§

impl<K, V, F> Unpin for RcuHashMap<K, V, F>

§

impl<K, V, F> UnwindSafe for RcuHashMap<K, V, F>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.