Blender V5.3
blender::ConcurrentSet< Key, Hash, IsEqual > Class Template Reference

#include <BLI_concurrent_set.hh>

Inherits blender::blender::NonCopyable.

Public Member Functions

 ConcurrentSet ()=default
 ConcurrentSet (ConcurrentSet &&other) noexcept
ConcurrentSet & operator= (ConcurrentSet &&other) noexcept
template<typename ForwardKey>
const Key * lookup_ptr (const ForwardKey &key) const
const Key & lookup_key_or_add (const Key &key)
const Key & lookup_key_or_add (Key &&key)
template<typename ForwardKey>
const Key & lookup_key_or_add_as (ForwardKey &&key)
int64_t size () const
void reserve (const int64_t n)

Detailed Description

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

A ConcurrentSet allows adding and looking up keys from multiple threads concurrently. Once a key has been added, a pointer to it remains valid for as long as the set exists (keys are never relocated by growth).

This is a thin wrapper around #tbb::concurrent_unordered_set that also has a fallback implementation if TBB is not available. The fallback implementation is not optimized.

Definition at line 34 of file BLI_concurrent_set.hh.

Constructor & Destructor Documentation

◆ ConcurrentSet() [1/2]

template<typename Key, typename Hash = DefaultHash<Key>, typename IsEqual = DefaultEquality<Key>>
blender::ConcurrentSet< Key, Hash, IsEqual >::ConcurrentSet ( )
default

◆ ConcurrentSet() [2/2]

template<typename Key, typename Hash = DefaultHash<Key>, typename IsEqual = DefaultEquality<Key>>
blender::ConcurrentSet< Key, Hash, IsEqual >::ConcurrentSet ( ConcurrentSet< Key, Hash, IsEqual > && other)
inlinenoexcept

Definition at line 141 of file BLI_concurrent_set.hh.

Member Function Documentation

◆ lookup_key_or_add() [1/2]

template<typename Key, typename Hash = DefaultHash<Key>, typename IsEqual = DefaultEquality<Key>>
const Key & blender::ConcurrentSet< Key, Hash, IsEqual >::lookup_key_or_add ( const Key & key)
inline

Add the key to the set if it does not exist yet. Either way, a reference to the key that is now stored in the set is returned (which might not be the passed in key, if another thread added an equal key first).

Definition at line 168 of file BLI_concurrent_set.hh.

Referenced by blender::detail::ustring_ensure_entry().

◆ lookup_key_or_add() [2/2]

template<typename Key, typename Hash = DefaultHash<Key>, typename IsEqual = DefaultEquality<Key>>
const Key & blender::ConcurrentSet< Key, Hash, IsEqual >::lookup_key_or_add ( Key && key)
inline

Definition at line 172 of file BLI_concurrent_set.hh.

◆ lookup_key_or_add_as()

template<typename Key, typename Hash = DefaultHash<Key>, typename IsEqual = DefaultEquality<Key>>
template<typename ForwardKey>
const Key & blender::ConcurrentSet< Key, Hash, IsEqual >::lookup_key_or_add_as ( ForwardKey && key)
inline

Definition at line 176 of file BLI_concurrent_set.hh.

◆ lookup_ptr()

template<typename Key, typename Hash = DefaultHash<Key>, typename IsEqual = DefaultEquality<Key>>
template<typename ForwardKey>
const Key * blender::ConcurrentSet< Key, Hash, IsEqual >::lookup_ptr ( const ForwardKey & key) const
inline

Look up a key without adding it. Returns null if the key does not exist yet. Does not require creating a Key first, unlike lookup_key_or_add.

Definition at line 156 of file BLI_concurrent_set.hh.

Referenced by blender::detail::ustring_ensure_entry().

◆ operator=()

template<typename Key, typename Hash = DefaultHash<Key>, typename IsEqual = DefaultEquality<Key>>
ConcurrentSet & blender::ConcurrentSet< Key, Hash, IsEqual >::operator= ( ConcurrentSet< Key, Hash, IsEqual > && other)
inlinenoexcept

Definition at line 145 of file BLI_concurrent_set.hh.

◆ reserve()

template<typename Key, typename Hash = DefaultHash<Key>, typename IsEqual = DefaultEquality<Key>>
void blender::ConcurrentSet< Key, Hash, IsEqual >::reserve ( const int64_t n)
inline

Potentially grow the set so that it can hold at least #n keys without rehashing again.

Definition at line 190 of file BLI_concurrent_set.hh.

Referenced by blender::global_string_table().

◆ size()

template<typename Key, typename Hash = DefaultHash<Key>, typename IsEqual = DefaultEquality<Key>>
int64_t blender::ConcurrentSet< Key, Hash, IsEqual >::size ( ) const
inline

Returns the number of keys currently in the set.

Definition at line 183 of file BLI_concurrent_set.hh.


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