Expand description
§ev_slotmap
A lock-free, concurrent slot map. Most of this library is a rip off of Jon Gjengset’s evmap but with a few notable simplifications
- The value-bag map is replaced with a one-way slotmap
- No batched edits (required because slot map keys need to be returned on insert)
- No associated metadata
The core synchronization component’s of evmap are still present. Out of simplicity, we also use the ShallowCopy straight out of evmap instead of copy-pasting it in. Also the following blurb is almost straight from evmap.
This map implementation allows reads and writes to execute entirely in parallel, with no
implicit synchronization overhead. Reads never take locks on their critical path, and neither
do writes assuming there is a single writer (multi-writer is possible using a Mutex
), which
significantly improves performance under contention.
Unlike evmap which provides eventual consistency following explicit refresh
calls, synchronization between reads and writers happens before write methods
return. For read-heavy workloads, the scheme used by this module is particularly
useful. Writers can afford to refresh after every write, which provides up-to-date
reads, and readers remain fast as they do not need to ever take locks.
Structs§
- MapRead
Ref - A live reference into the read half of an evmap.
- Read
Guard - A guard wrapping a live reference into an ev slotmap.
- Read
Handle - A handle that may be used to read from the concurrent slot map.
- Read
Handle Factory - A type that is both
Sync
andSend
and lets you produce newReadHandle
instances. - Write
Handle - A handle that may be used to modify the concurrent map.
Functions§
- new
- Create an empty ev slotmap.
- new_
with_ data - Create a new evmap with the given data