ConcurrentVectorMemoryPool#

Fully qualified name: usd_optimize::ConcurrentVectorMemoryPool

Classes Summary#

Vec

Scoped wrapper around a memory pool allocated vector. This means the vector is deallocated when the wrapper goes out of scope.

template<typename T>
class ConcurrentVectorMemoryPool#

Manages a pool of vectors of type T that can be accessed concurrently. If there are no free vectors available, a new one is allocated. Note: this does not garbage collect, the destructor or clear must be called to release memory.

Public Functions

inline ConcurrentVectorMemoryPool(bool active)#
inline ~ConcurrentVectorMemoryPool()#
ConcurrentVectorMemoryPool(const ConcurrentVectorMemoryPool&) = delete#
ConcurrentVectorMemoryPool &operator=(
const ConcurrentVectorMemoryPool&,
) = delete#
inline void setActive(bool active)#

Sets whether this memory pool is active or not. If it is not active, then all vectors are allocated directly and not from the pool note: this function calls clear so it is not thread safe and should only be called when no other threads are using the pool.

inline Vec allocate(size_t size = 0)#

Either allocates a new vector or returns an existing one from the pool.

Parameters:

size – The minimum size that the vector should have of reserved memory.

inline void clear()#

Frees all vectors in the pool. Warning: Calling clear is not thread safe and should only be called when no other threads are using the pool.

Protected Functions

inline void deallocate(std::vector<T> *vec)#

Returns the vector to the pool. The vector must have been allocated from this pool.

class Vec#

Scoped wrapper around a memory pool allocated vector. This means the vector is deallocated when the wrapper goes out of scope.

Public Functions

inline ~Vec()#
Vec(const Vec&) = delete#
Vec &operator=(const Vec&) = delete#
inline std::vector<T> &get()#

Protected Functions

inline Vec(
ConcurrentVectorMemoryPool &memPool,
std::vector<T> *vec,
)#

Friends

friend class ConcurrentVectorMemoryPool