HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_ConcurrentVector.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_ConcurrentVector.h (UT Library, C++)
7  *
8  * COMMENTS: Wrapper around Intel TBB's concurrent_vector container.
9  *
10  */
11 
12 #ifndef __UT_CONCURRENTVECTOR_H_INCLUDED__
13 #define __UT_CONCURRENTVECTOR_H_INCLUDED__
14 
15 #include "UT_API.h"
16 #include <SYS/SYS_BitUtil.h>
17 #include <SYS/SYS_Types.h>
18 #include <tbb/concurrent_vector.h>
19 
20 // Due to current C++ inadequacies, we have to wrap the TBB template classes
21 // using a define
22 /// @see UT_ConcurrentQueue
23 #define UT_ConcurrentVector tbb::concurrent_vector
24 
25 template<typename T, typename A>
26 int64
27 UTgetMemoryUsage(const UT_ConcurrentVector<T,A> &that, bool inclusive)
28 {
29  int64 mem = inclusive ? sizeof(that) : 0;
30 
31  // The data content
32  mem += that.capacity() * sizeof(T);
33 
34  // NOTE: This is based on TBB using an array of pointers to
35  // doubling-length arrays. If the capacity is 8 or less, it uses
36  // 3 pointers internal to the structure (2, 2, and 4 elements each).
37  if (that.capacity() > 8)
38  mem += SYSceilLog2(that.capacity()) * sizeof(void*);
39 
40  return mem;
41 }
42 
43 #endif // __UT_CONCURRENTVECTOR_H_INCLUDED__
long long int64
Definition: SYS_Types.h:116
int64 UTgetMemoryUsage(const UT_ConcurrentVector< T, A > &that, bool inclusive)