HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_ConcurrentHashMap.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_hash_map 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_CONCURRENTHASHMAP_H_INCLUDED__
16 #define __UT_CONCURRENTHASHMAP_H_INCLUDED__
17 
18 #include "UT_API.h"
19 #include <SYS/SYS_Types.h>
20 #include <tbb/concurrent_hash_map.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_ConcurrentHashMap tbb::concurrent_hash_map
26 
27 template<typename K, typename V, typename H, typename A>
28 int64
29 UTgetMemoryUsage(const UT_ConcurrentHashMap<K, V, H, A> &map, const bool inclusive)
30 {
31  int64 mem = 0;
32  if (inclusive)
33  mem += sizeof(map);
34 
35  // The size of the buckets (a mutex and a pointer to the first node)
36  mem += map.bucket_count()*(sizeof(intptr_t) + sizeof(void *));
37  // The size of the nodes (a mutex, a pointer to the next node,
38  // and an std::pair<K,V> forthe key and value)
39  mem += map.size()*(sizeof(intptr_t) + sizeof(void *) + sizeof(std::pair<K,V>));
40 
41  return mem;
42 }
43 
44 #endif // __UT_CONCURRENTHASHMAP_H_INCLUDED__
long long int64
Definition: SYS_Types.h:116
int64 UTgetMemoryUsage(const UT_ConcurrentHashMap< K, V, H, A > &map, const bool inclusive)