pub struct AtomicMap<K, V>where
    K: PartialEq,{ /* private fields */ }

Implementations§

source§

impl<K, V> AtomicMap<K, V>where K: PartialEq,

source

pub const fn new() -> AtomicMap<K, V>

Create a new empty AtomicMap.

Does not perform any allocation until a new node is created.

source

pub fn insert(&self, key: K, value: V) -> Option<V>

Adds a new key-value pair to the map. If the given key is already present, its corresponding value will be overwritten.

source

pub fn insert_timeout( &self, key: K, value: V, max_attempts: u64 ) -> Result<Option<V>, V>

Adds a new key-value pair to the map. If the given key is already present, its corresponding value will be overwritten. If it fails to do so atomically after the given number of attempts, it will abort and return Err.

source

pub fn get(&self, key: &K) -> Option<&V>

Returns a reference to the value matching the given key, if present. Otherwise, returns None.

source

pub fn get_mut(&mut self, key: K) -> Option<&mut V>

Returns a mutable reference to the value matching the given key, if present. Otherwise, returns None. In order to maintain memory safety (to ensure atomicity), getting a value as mutable requires self (this AtomicMap instance) to be borrowed mutably.

source

pub fn iter(&self) -> AtomicMapIter<'_, K, V>

Returns a forward iterator through this map.

Trait Implementations§

source§

impl<K, V: Debug> Debug for AtomicMap<K, V>where K: PartialEq + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<K, V> Drop for AtomicMap<K, V>where K: PartialEq,

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<K, V> RefUnwindSafe for AtomicMap<K, V>

§

impl<K, V> Send for AtomicMap<K, V>

§

impl<K, V> Sync for AtomicMap<K, V>

§

impl<K, V> Unpin for AtomicMap<K, V>

§

impl<K, V> UnwindSafe for AtomicMap<K, V>where K: RefUnwindSafe, V: RefUnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.