29      : blocksPerChunk{blocksPerChunk} {}
 
 
   44                                   alignof(std::max_align_t)) {
 
   45    if (m_freeList.empty()) {
 
   49    auto ptr = m_freeList.back();
 
   50    m_freeList.pop_back();
 
 
   62      void* p, [[maybe_unused]] 
size_t bytes,
 
   63      [[maybe_unused]] 
size_t alignment = 
alignof(std::max_align_t)) {
 
   64    m_freeList.emplace_back(p);
 
 
   71    return this == &other;
 
 
   78    return m_buffer.size() * blocksPerChunk - m_freeList.size();
 
 
   84  size_t blocksPerChunk;
 
   92  void AddChunk(
size_t bytesPerBlock) {
 
   93    m_buffer.
emplace_back(
new std::byte[bytesPerBlock * blocksPerChunk]);
 
   94    for (
int i = blocksPerChunk - 1; i >= 0; --i) {
 
 
  130    return static_cast<T*
>(m_memoryResource->
allocate(n));
 
 
 
This file defines the SmallVector class.
#define SLEIPNIR_DLLEXPORT
Definition SymbolExports.hpp:34
This class is an allocator for the pool resource.
Definition Pool.hpp:106
constexpr PoolAllocator< T > & operator=(const PoolAllocator< T > &)=default
constexpr T * allocate(size_t n)
Returns a block of memory from the pool.
Definition Pool.hpp:129
constexpr PoolAllocator(const PoolAllocator< T > &other)=default
constexpr PoolAllocator(PoolResource *r)
Constructs a pool allocator with the given pool memory resource.
Definition Pool.hpp:118
constexpr void deallocate(T *p, size_t n)
Gives a block of memory back to the pool.
Definition Pool.hpp:139
T value_type
The type of object in the pool.
Definition Pool.hpp:111
This class implements a pool memory resource.
Definition Pool.hpp:21
void * allocate(size_t bytes, size_t alignment=alignof(std::max_align_t))
Returns a block of memory from the pool.
Definition Pool.hpp:43
PoolResource & operator=(const PoolResource &)=delete
PoolResource(PoolResource &&)=default
PoolResource & operator=(PoolResource &&)=default
PoolResource(size_t blocksPerChunk)
Constructs a default PoolResource.
Definition Pool.hpp:28
size_t blocks_in_use() const noexcept
Returns the number of blocks from this pool resource that are in use.
Definition Pool.hpp:77
void deallocate(void *p, size_t bytes, size_t alignment=alignof(std::max_align_t))
Gives a block of memory back to the pool.
Definition Pool.hpp:61
bool is_equal(const PoolResource &other) const noexcept
Returns true if this pool resource has the same backing storage as another.
Definition Pool.hpp:70
PoolResource(const PoolResource &)=delete
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition SmallVector.h:1212
reference emplace_back(ArgTypes &&... Args)
Definition SmallVector.h:953
reference back()
Definition SmallVector.h:324
Definition Hessian.hpp:18
PoolAllocator< T > GlobalPoolAllocator()
Returns an allocator for a global pool memory resource.
Definition Pool.hpp:158
SLEIPNIR_DLLEXPORT PoolResource & GlobalPoolResource()
Returns a global pool memory resource.