Concurrent Operations: find, insert, erase
The operations find, insert, and erase are the only operations that may be concurrently invoked on the same concurrent_hash_map. These operations search the table for a key-value pair that matches a given key. The find and insert methods each have two variants. One takes a const_accessor argument and provides read-only access to the desired key-value pair. The other takes an accessor argument and provides write access.
Warning
If the non-const variant succeeds in finding the key, the consequent write access blocks any other thread from accessing the key until the accessor object is destroyed. Where possible, use the const variant to improve concurrency.
The result of the map operation is true if the operation succeeds.
-
bool find( const_accessor&result, const Key& key )const Effects: searches a table for a pair with the given key. If the key is found, provides read-only access to the matching pair.
Returns:
trueif the key is found;falseif the key is not found.-
bool find( accessor& result, const Key& key ) Effects: searches a table for a pair with the given key. If the key is found, provides write access to the matching pair.
Returns:
trueif the key is found;falseif the key is not found.-
bool insert( const_accessor& result, const Key& key ) Effects: searches a table for a pair with the given key. If not present, inserts a new pair into the table. The new pair is initialized with
pair(key,T()). Provides read-only access to the matching pair. ...