Module concache::crossbeam [−][src]
A concurrent hash map implementation with crossbeam memory reclamation.
This implementation provides a lock-free hash map using buckets that hold lock-free linked
lists.
Memory is safely destructed and reclaimed using
crossbeam::epoch
. Table resizing is not yet supported,
but the map will also never fill due to the linked implementation; instead, performance will
decrease as the map is filled with more keys.
The interface to this map is somewhat different from HashMap
to support concurrent operation.
When you create a new Map
,you are given a MapHandle
, which allows access to the map's
data. To read or mutate the map for elsewhere, you call [MapHandle::clone
], which gives you
a new MapHandle
that provides concurrent access to the same map.
Similarly to crossbeam::epoch
, this Map
does not
guarantee that destructors are called. In practice though, as long as threads do not leak
MapHandle
s, destructors will all eventually be called.
Note that unlike HashMap
, this Map
requires its values to be Copy
. This greatly
simplifies the map's interface; accesses to the map's data have to be carefully guarded, and
there is no simple way to expose references into the map through a method call. Later, we may
provide temporary access through closures, similar to evmap
's
ReadHandle::get_and
,
but for the time being, values have to be Copy
.
Structs
MapHandle |
A handle to a shared |
Type Definitions
Map |
A shared, concurrent hash map. |