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 <tbb/concurrent_unordered_set.h>
21 #include <utility>
22 
23 // Due to current C++ inadequacies, we have to wrap the TBB template classes
24 // using a define
25 #define UT_ConcurrentSet tbb::concurrent_unordered_set
26 
27 template<typename K, typename H, typename E, typename A>
28 int64
29 UTgetMemoryUsage(const UT_ConcurrentSet<K, H, E, A> &set, const bool inclusive)
30 {
31  int64 mem = 0;
32  if (inclusive)
33  mem += sizeof(set);
34 
35  // The size of the buckets (a mutex and a pointer to the first node)
36  mem += set.bucket_count()*(sizeof(intptr_t) + sizeof(void *));
37  // The size of the nodes (a mutex, a pointer to the next node,
38  // and a K for the value)
39  mem += set.size()*(sizeof(intptr_t) + sizeof(void *) + sizeof(K));
40 
41  return mem;
42 }
43 
44 #endif // __UT_CONCURRENTSET_H_INCLUDED__
int64 UTgetMemoryUsage(const UT_ConcurrentSet< K, H, E, A > &set, const bool inclusive)
long long int64
Definition: SYS_Types.h:116