HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UT_ConcurrentQueue.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_ConcurrentQueue.h (UT Library, C++)
7  *
8  * COMMENTS: Wrapper around Intel TBB's concurrent_queue container.
9  */
10 
11 #ifndef __UT_CONCURRENTQUEUE_H_INCLUDED__
12 #define __UT_CONCURRENTQUEUE_H_INCLUDED__
13 
14 #include "UT_API.h"
15 #include <tbb/concurrent_queue.h>
16 #include <SYS/SYS_Types.h>
17 
18 // Due to current C++ inadequacies, we have to wrap the TBB template classes
19 // using a define
20 /// @see UT_ConcurrentVector
21 #define UT_ConcurrentQueue tbb::concurrent_queue
22 
23 template<typename T, typename A>
24 int64
25 UTgetMemoryUsage(const UT_ConcurrentQueue<T, A> &queue, const bool inclusive)
26 {
27  int64 mem = 0;
28  if (inclusive)
29  mem += sizeof(queue);
30 
31  // NOTE: The internals of tbb::concurrent_queue are a bit of a mystery, so
32  // just count what we know is there, for now.
33  mem += queue.unsafe_size()*sizeof(T);
34 
35  return mem;
36 }
37 
38 #endif // __UT_CONCURRENTQUEUE_H_INCLUDED__
long long int64
Definition: SYS_Types.h:100
int64 UTgetMemoryUsage(const UT_ConcurrentQueue< T, A > &queue, const bool inclusive)