[][src]Struct lockfreehashmap::map_inner::MapInner

pub struct MapInner<'v, K, V: 'v, S = RandomState> {
    map: Vec<(AtomicPtr<KeySlot<K>>, AtomicPtr<ValueSlot<'v, V>>)>,
    size: AtomicUsize,
    pub(crate) newer_map: AtomicPtr<MapInner<'v, K, V, S>>,
    resizers_count: AtomicUsize,
    chunks_copied: AtomicUsize,
    slots_copied: AtomicUsize,
    hash_builder: S,
}

A map containing a unique, non-resizable array to the Key/Value pairs. If the map needs to be resized, a new MapInner must be created and its Key/Value pairs must be copied from this one. Logically, this struct owns its keys and values, and so is responsible for freeing them when dropped.

Fields

The key/value pairs in this map, allocated as an array of pairs.

The amount of key/value pairs in the array, if any.

Points to the newer map or null if none.

Any thread can allocate memory to resize the map and create newer_map. Thus, we want to try and limit the amount of allocations done. This is a monotonically increasing count of the number of threads currently trying to allocate a new map, which is used as a heuristic. See its use in the MapInner::create_newer_map() function.

The number of ::COPY_CHUNK_SIZE = 32 element chunks that some thread has commited to copying to the newer table. Once this reaches capacity/COPY_CHUNK_SIZE, we know that the entire map has been copied into the large newer_map.

The actual number of key/value pairs that have been copied into the newer map.

The hasher used to hash keys.

Methods

impl<'v, K, V, S> MapInner<'v, K, V, S>
[src]

The default size of a new LockFreeHashMap.

Returns the capacity of the current map; i.e. the length of the Vec storing the key/value pairs.

Returns the size of the current map at some point in time; i.e. the number of key/value pairs in the map.

Drops self.newer_map and any newer maps that self.newer_map points to.

Drops self, self.newer_map and any newer maps that self.newer_map points to.

impl<'v, K: Hash + Eq, V: PartialEq> MapInner<'v, K, V, RandomState>
[src]

Creates a new MapInner. Uses the next power of two if size is not a power of two.

impl<'guard, 'v: 'guard, K, V, S> MapInner<'v, K, V, S> where
    K: Hash + Eq,
    V: PartialEq,
    S: BuildHasher + Clone
[src]

Help copy a small chunk of the map to the newer_map. See ::COPY_CHUNK_SIZE for the default chunk size.

Once a MapInner has had all its elements copied to its newer_map field, the LockFreeHashMap's inner field must be promoted so that its effects are visible globally.

Copies a single key/value pair from the map in &self to the map in &self.newer_map.

Returns whether or not this thread was the one to copy the slot. Since copying takes several transitions that could happen from any thread, it doesn't matter which transition we pick as long as exactly one thread reports true for copying a specific slot.

If newer_map doesn't exist, then this function tries to allocate a newer map that's double the size of self.

Returns a Shared pointer to the newer map

Returns the current value associated with some key, if any.

Increments or decrements the current size of the map, returning the previous value in the map.

Trait Implementations

impl<'v, K, V, S> Drop for MapInner<'v, K, V, S>
[src]

Executes the destructor for this type. Read more

impl<'v, K: Debug, V: Debug + 'v, S: Debug> Debug for MapInner<'v, K, V, S>
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<'v, K, V, S> Send for MapInner<'v, K, V, S> where
    K: Send + Sync,
    S: Send + Sync,
    V: Send + Sync

impl<'v, K, V, S> Sync for MapInner<'v, K, V, S> where
    K: Send + Sync,
    S: Send + Sync,
    V: Send + Sync

Blanket Implementations

impl<T> From for T
[src]

Performs the conversion.

impl<T, U> Into for T where
    U: From<T>, 
[src]

Performs the conversion.

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Borrow for T where
    T: ?Sized
[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut for T where
    T: ?Sized
[src]

Mutably borrows from an owned value. Read more

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

🔬 This is a nightly-only experimental API. (get_type_id)

this method will likely be replaced by an associated static

Gets the TypeId of self. Read more