Import std.concurrent.concurrent_map
std.concurrent.concurrent_map
ConcurrentMap<K, V>: a hash map that any number of threads change and read at once. Its
entries are in 16 parts, by the top bits of their keys' hashes once they're mixed, each part an
ImmutableMap behind a Mutex of its own, so threads that change different parts don't wait for
each other. A read copies its part's ImmutableMap, which shares its nodes, and looks in the
copy, holding the lock only for that, and a For ... In goes over a copy of each part. A value is
in a Shared cell of its own, so a change worked out from a copy can tell whether another thread
changed the key meanwhile. A change keeps the entries it replaces in a Local until it holds no
lock, so a Destroy that the letting go runs can use the map.
std/concurrent/concurrent_map.fb
Types
ConcurrentMap
class
Public Shared Class ConcurrentMap<K, V> Implements Iterable<(K, V)>, Defaultable
A Map that threads share, which each Get, Set, and Remove changes or reads whole, in parts, so threads that use different keys don't wait for each other.
std/concurrent/concurrent_map.fb, line 39
-
A new, empty ConcurrentMap.
-
How many entries there are, which other threads may change at any time.
-
Adds an entry, or gives an existing
keyits new value. Panics when the ConcurrentMap has as many entries as an Int counts. -
Adds an entry when the
keyisn't there, and tells whether it wasn't. Panics when the ConcurrentMap has as many entries as an Int counts. -
The
key's value, or Null when it isn't there. -
The
key's value, orfallbackwhen it isn't there. -
The
key's value, adding whatmakegives for it first when it isn't there. Threads that ask for a key at once may each runmake, but the map keeps the first value added, which they all get. Panics, as Add does, when there's no room for thekey. -
Gives the
key's value whatchangegives for it, and tells whether thekeywas there. When another thread changes thekey's value meanwhile,changeruns again, on the value that thread gave it, so no change is lost. -
Adds
valuefor thekeywhen it isn't there, or gives its value whatchangegives for it, and gives thevaluethekeyhas now. When another thread changes thekeymeanwhile,changeruns again, as in Update. Panics, as Add does, when there's no room for thekey. -
The key's value. Panics when the key isn't there.
-
Gives the key a value, adding it when it isn't there, as Add does.
-
Whether
keyhas an entry. -
Removes the
key's entry, and tells whether there was one. -
Removes every entry.
-
The keys, in the order a For ... In gives them.
-
The values, in their keys' order.
-
A new Map with the entries, in the order a For ... In gives them.
-
A new, empty ConcurrentMap.
-
Each key and its value, part by part, by their keys' hashes in a part, and keys of one hash in the order they were added. It goes over a copy of each part, made as it comes to it, so what other threads do meanwhile never stops it.
ConcurrentMapIterator
struct
Public Struct ConcurrentMapIterator<K, V> Implements Iterator<(K, V)>
The entries of a ConcurrentMap as they were when the loop began, which For ... In goes over.
std/concurrent/concurrent_map.fb, line 285
-
The next value, or Null when there are no more.
Doc from
std.core.iterator.Iterator.Next.
Report an issue with this page or with FutureBlitz on GitHub.