37 #ifndef NEKTAR_LIB_UTILITIES_NEK_MEMORY_MANAGER_H
38 #define NEKTAR_LIB_UTILITIES_NEK_MEMORY_MANAGER_H
41 #include <type_traits>
43 #include <boost/core/ignore_unused.hpp>
82 template<
typename DataType>
101 #ifdef NEKTAR_MEMORY_POOL_ENABLED
111 #ifdef NEKTAR_MEMORY_POOL_ENABLED
119 template<
typename... Args>
120 static DataType*
Allocate(
const Args &...args)
122 DataType* result =
static_cast<DataType*
>(
129 new (result) DataType(args...);
148 template<typename... Args>
151 return new DataType(args...);
160 template<
typename... Args>
166 template<
typename DeallocatorType,
typename... Args>
168 const DeallocatorType& d,
const Args &...args)
171 return std::shared_ptr<DataType>(
172 data, [=](DataType *ptr){
190 #ifdef NEKTAR_MEMORY_POOL_ENABLED
193 return static_cast<DataType*
>(::operator
new(NumberOfElements *
sizeof(DataType)));
206 #ifdef NEKTAR_MEMORY_POOL_ENABLED
209 ::operator
delete(array);
231 boost::ignore_unused(
rhs);
240 boost::ignore_unused(hint);
251 new(
p) DataType(val);
261 return std::numeric_limits<size_type>::max()/
sizeof(DataType);
278 template<
typename DataType>
281 boost::ignore_unused(
lhs,
rhs);
285 template<
typename DataType>
void Deallocate(void *p, size_t bytes)
Deallocate memory claimed by an earlier call to allocate.
void * Allocate(size_t bytes)
Allocate a block of memory of size ByteSize.
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
static std::shared_ptr< DataType > AllocateSharedPtrD(const DeallocatorType &d, const Args &...args)
void deallocate(pointer p, size_type n)
MemoryManager(const MemoryManager< T > &rhs)
pointer address(reference r) const
ptrdiff_t difference_type
const DataType * const_pointer
const DataType & const_reference
static void RawDeallocate(DataType *array, size_t NumberOfElements)
Deallocates memory allocated from RawAllocate.
void construct(pointer p, const_reference val)
static void Deallocate(DataType *&data)
Deallocate a pointer allocated by MemoryManager::Allocate.
pointer allocate(size_type n, std::allocator< void >::const_pointer hint=0)
static DataType * Allocate(const Args &...args)
Allocates a single object from the memory pool.
const_pointer address(const_reference r) const
static DataType * RawAllocate(size_t NumberOfElements)
Allocates a chunk of raw, uninitialized memory, capable of holding NumberOfElements objects.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs
bool operator==(const Array< OneD, NekDouble > &lhs, const Array< OneD, NekDouble > &rhs)
MemPool & GetMemoryPool()
bool operator!=(const Array< OneD, T1 > &lhs, const Array< OneD, T2 > &rhs)