27 #ifndef UT_MemoryPool_h 28 #define UT_MemoryPool_h 33 #include <spatialops/structured/MemoryTypes.h> 42 typedef std::stack<T*> Queue;
44 FieldQueue(){ accessCounter=0; }
47 typedef std::map<size_t,FieldQueue> FQSizeMap;
48 typedef std::map<T*,size_t> FieldSizeMap;
50 static bool destroyed_;
52 size_t accessCounter_;
54 FQSizeMap cpufqm_, gpufqm_;
56 size_t cpuhighWater_, gpuhighWater_;
60 Pool& operator=(
const Pool&);
64 const unsigned short int deviceIndex_;
79 static T*
get(
const short int deviceLocation,
const size_t n );
87 static void put(
const short int deviceLocation, T* t );
97 static size_t total();
107 template<
typename T>
bool Pool<T>::destroyed_ =
false;
130 : ptr(ptr), activeIndex(activeIndex)
136 inline T*
get() {
return ptr; }
137 inline const T*
get()
const {
return ptr; }
142 inline operator T*() {
return ptr; }
143 inline operator const T*()
const {
return ptr; }
149 inline const T& operator*()
const {
return *ptr; }
155 inline const T* operator->()
const {
return ptr; }
164 const short int activeIndex;
static size_t flush_unused(const size_t n)
remove fields that have not been used for more than n calls to the pool
T * operator->()
allow pointer like interaction
static void put(const short int deviceLocation, T *t)
Return the requested block of memory to the pool. This should only be done for memory requested from ...
takes ownership over memory allocated from the pool and puts the memory back into the pool when it is...
PoolAutoPtr(T *ptr, short int activeIndex)
PoolAutoPtr constructor which takes ownership over ptr.
T & operator*()
return reference to managed memory
~PoolAutoPtr()
put managed memory back into other pool on destruction