Blender V4.3
blender::ConcurrentMap< Key, Value, Hash, IsEqual > Class Template Reference

#include <BLI_concurrent_map.hh>

Public Types

using size_type = int64_t
 
using MutableAccessor = Accessor
 
using ConstAccessor = Accessor
 

Public Member Functions

bool lookup (Accessor &accessor, const Key &key)
 
bool add (Accessor &accessor, const Key &key)
 
bool remove (const Key &key)
 

Detailed Description

template<typename Key, typename Value, typename Hash = DefaultHash<Key>, typename IsEqual = DefaultEquality<Key>>
class blender::ConcurrentMap< Key, Value, Hash, IsEqual >

A #ConcurrentMap allows adding, removing and looking up values from multiple threads concurrently. It has higher memory and performance overhead than a simple #Map when not used concurrently though.

For thread-safety, one always has the use an accessor to retrieve or update values. This makes sure that only one thread can modify a value at a time. Multiple threads may read from the same key at the same time though.

Note
#ConcurrentMap does not support iteration over all values.

This is a thin wrapper around #tbb::concurrent_hash_map that also has a fallback implementation if TBB is not available. The fallback implementation is not optimized for performance. It mainly intends to be a simple implementation that can compile whenever the TBB variant can compile.

Definition at line 55 of file BLI_concurrent_map.hh.

Member Typedef Documentation

◆ ConstAccessor

template<typename Key , typename Value , typename Hash = DefaultHash<Key>, typename IsEqual = DefaultEquality<Key>>
using blender::ConcurrentMap< Key, Value, Hash, IsEqual >::ConstAccessor = Accessor

Definition at line 181 of file BLI_concurrent_map.hh.

◆ MutableAccessor

template<typename Key , typename Value , typename Hash = DefaultHash<Key>, typename IsEqual = DefaultEquality<Key>>
using blender::ConcurrentMap< Key, Value, Hash, IsEqual >::MutableAccessor = Accessor

Definition at line 180 of file BLI_concurrent_map.hh.

◆ size_type

template<typename Key , typename Value , typename Hash = DefaultHash<Key>, typename IsEqual = DefaultEquality<Key>>
using blender::ConcurrentMap< Key, Value, Hash, IsEqual >::size_type = int64_t

Definition at line 57 of file BLI_concurrent_map.hh.

Member Function Documentation

◆ add()

template<typename Key , typename Value , typename Hash = DefaultHash<Key>, typename IsEqual = DefaultEquality<Key>>
bool blender::ConcurrentMap< Key, Value, Hash, IsEqual >::add ( Accessor & accessor,
const Key & key )
inline

Definition at line 194 of file BLI_concurrent_map.hh.

Referenced by blender::memory_cache::get_base().

◆ lookup()

template<typename Key , typename Value , typename Hash = DefaultHash<Key>, typename IsEqual = DefaultEquality<Key>>
bool blender::ConcurrentMap< Key, Value, Hash, IsEqual >::lookup ( Accessor & accessor,
const Key & key )
inline

◆ remove()

template<typename Key , typename Value , typename Hash = DefaultHash<Key>, typename IsEqual = DefaultEquality<Key>>
bool blender::ConcurrentMap< Key, Value, Hash, IsEqual >::remove ( const Key & key)
inline

The documentation for this class was generated from the following file: