#reference-counting #map #hash-map #thread-safe #mutex

mbarc-map

Implementation of a Minimally-blocking, Atomic Reference Counted Map

4 releases (2 breaking)

0.10.0 Oct 15, 2024
0.9.0 Mar 19, 2024
0.8.1 Mar 14, 2024
0.8.0 Mar 10, 2024

#766 in Concurrency

Download history 5/week @ 2024-07-27 15/week @ 2024-09-21 177/week @ 2024-10-12 14/week @ 2024-10-19

191 downloads per month

MIT license

48KB
863 lines

mbarc-map

Minimally-blocking, Atomic Reference Counted Map

Crates.io MIT licensed

API Docs

The motivation of the map implemented in this crate is to provide a map that is better suited towards concurrent use. This crate attempts to solve two problems:

  • Need to be able to refer to map elements without keeping the map itself locked
  • Data stored within the map should be stored in a way that is as cache-friendly as possible for efficient iteration

Individually, these aren't huge asks, but achieving both of these properties while satisfying rust ended up being complex enough to be worth wrapping, thus leading to the creation of MbarcMap. You can kind of think of MbarcMap<T,U> as a shorthand for: Mutex<HashMap<T,Arc<Mutex<U>>>>, however there's more to it than that, especially in regards to pointer safety (stored values are never moved), memory layout (data is stored in continuous blocks), and iterators (safe to alter the map while iterating over it)

No runtime deps