pub struct SyncMapImpl<K: Eq + Hash + Clone + Ord, V> { /* private fields */ }
Expand description

this sync map used to many reader,writer less.space-for-time strategy

Map is like a Go map[interface{}]interface{} but is safe for concurrent use by multiple goroutines without additional locking or coordination. Loads, stores, and deletes run in amortized constant time.

The Map type is specialized. Most code should use a plain Go map instead, with separate locking or coordination, for better type safety and to make it easier to maintain other invariants along with the map content.

The Map type is optimized for two common use cases: (1) when the entry for a given key is only ever written once but read many times, as in caches that only grow, or (2) when multiple goroutines read, write, and overwrite entries for disjoint sets of keys. In these two cases, use of a Map may significantly reduce lock contention compared to a Go map paired with a separate Mutex or RWMutex.

The zero Map is empty and ready for use. A Map must not be copied after first use.

Implementations

Returns a reference to the value corresponding to the key.

The key may be any borrowed form of the map’s key type, but Hash and Eq on the borrowed form must match those for the key type.

Since reading a map is unlocked, it is very fast

test bench_sync_hash_map_read … bench: 8 ns/iter (+/- 0)

Examples
use dark_std::sync::{SyncBtreeMap};

let mut map = SyncBtreeMap::new();
map.insert_mut(1, "a");
assert_eq!(*map.get(&1).unwrap(), "a");
assert_eq!(map.get(&2).is_none(), true);

Trait Implementations

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Executes the destructor for this type. Read more

Converts to this type from the input type.

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

Serialize this value into the given Serde serializer. Read more

this is safety, dirty mutex ensure

this is safety, dirty mutex ensure

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.