HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_ConcurrentSet.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_ConcurrentHashMap.h (UT Library, C++)
7  *
8  * COMMENTS: Wrapper around Intel TBB's concurrent_unordered_set container.
9  * Microsoft will probably have an implementation of this in their
10  * Concurrent Runtime Parallel Patterns Library (PPL) since they
11  * already have concurrent_vector and concurrent_queue.
12  *
13  */
14 
15 #ifndef __UT_CONCURRENTSET_H_INCLUDED__
16 #define __UT_CONCURRENTSET_H_INCLUDED__
17 
18 #include "UT_API.h"
19 #include <SYS/SYS_Types.h>
20 #include <hboost/container_hash/hash.hpp>
21 #include <oneapi/tbb/concurrent_unordered_set.h>
22 #include <utility>
23 
24 
25 template
26 <
27  typename K,
28  typename H = hboost::hash<K>,
29  typename P = std::equal_to<K>,
30  typename A = tbb::tbb_allocator<K>
31 >
32 using UT_ConcurrentSet = tbb::concurrent_unordered_set<K, H, P, A>;
33 
34 
35 template<typename K, typename H, typename E, typename A>
36 int64
37 UTgetMemoryUsage(const UT_ConcurrentSet<K, H, E, A> &set, const bool inclusive)
38 {
39  int64 mem = 0;
40  if (inclusive)
41  mem += sizeof(set);
42 
43  // The size of the buckets (a mutex and a pointer to the first node)
44  mem += set.bucket_count()*(sizeof(intptr_t) + sizeof(void *));
45  // The size of the nodes (a mutex, a pointer to the next node,
46  // and a K for the value)
47  mem += set.size()*(sizeof(intptr_t) + sizeof(void *) + sizeof(K));
48 
49  return mem;
50 }
51 
52 #endif // __UT_CONCURRENTSET_H_INCLUDED__
int64 UTgetMemoryUsage(const UT_ConcurrentSet< K, H, E, A > &set, const bool inclusive)
GA_API const UT_StringHolder P
constexpr auto set(type rhs) -> int
Definition: core.h:610
long long int64
Definition: SYS_Types.h:116
STATIC_INLINE uint64_t H(uint64_t x, uint64_t y, uint64_t mul, int r)
Definition: farmhash.h:762
tbb::concurrent_unordered_set< K, H, P, A > UT_ConcurrentSet