35#ifndef NEKTAR_LIBUTILITIES_OBJECTPOOL_HPP
36#define NEKTAR_LIBUTILITIES_OBJECTPOOL_HPP
42#include <boost/pool/pool.hpp>
43#include <boost/pool/pool_alloc.hpp>
48template <
typename DataType>
50 boost::fast_pool_allocator<DataType,
51 boost::default_user_allocator_new_delete,
52 boost::details::pool::null_mutex>;
63 template <
typename... Args>
static DataType *
Allocate(
const Args &...args)
65 DataType *ptr =
m_alloc.allocate();
66 new (ptr) DataType(args...);
84 template <
typename... Args>
88 return std::unique_ptr<DataType, UniquePtrDeleter>(
Allocate(args...));
96 std::unique_ptr<T, typename ObjPoolManager<T>::UniquePtrDeleter>;
Generic object pool allocator/deallocator.
static std::unique_ptr< DataType, UniquePtrDeleter > AllocateUniquePtr(const Args &...args)
static PoolAllocator< DataType > m_alloc
static void Deallocate(DataType *ptr)
static DataType * Allocate(const Args &...args)
boost::fast_pool_allocator< DataType, boost::default_user_allocator_new_delete, boost::details::pool::null_mutex > PoolAllocator
std::unique_ptr< T, typename ObjPoolManager< T >::UniquePtrDeleter > unique_ptr_objpool
void operator()(DataType *ptr) const