Skip to Main Content
Intel Threading Building Blocks
book

Intel Threading Building Blocks

by James Reinders
July 2007
Intermediate to advanced content levelIntermediate to advanced
332 pages
10h 4m
English
O'Reilly Media, Inc.
Content preview from Intel Threading Building Blocks

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: true if the key is found; false if 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: true if the key is found; false if 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. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Intel® Xeon Phi™ Coprocessor Architecture and Tools: The Guide for Application Developers

Intel® Xeon Phi™ Coprocessor Architecture and Tools: The Guide for Application Developers

Rezaur Rahman

Publisher Resources

ISBN: 9780596514808Errata Page