28 : blocksPerChunk{blocksPerChunk} {}
42 void*
allocate(
size_t bytes, [[maybe_unused]]
size_t alignment =
43 alignof(std::max_align_t)) {
44 if (m_freeList.empty()) {
48 auto ptr = m_freeList.back();
49 m_freeList.pop_back();
61 void* p, [[maybe_unused]]
size_t bytes,
62 [[maybe_unused]]
size_t alignment =
alignof(std::max_align_t)) {
63 m_freeList.emplace_back(p);
70 return this == &other;
77 return m_buffer.size() * blocksPerChunk - m_freeList.size();
83 size_t blocksPerChunk;
91 void AddChunk(
size_t bytesPerBlock) {
92 m_buffer.
emplace_back(
new std::byte[bytesPerBlock * blocksPerChunk]);
93 for (
int i = blocksPerChunk - 1; i >= 0; --i) {
129 return static_cast<T*
>(m_memoryResource->
allocate(
n));
#define SLEIPNIR_DLLEXPORT
Definition SymbolExports.hpp:34
constexpr PoolAllocator< T > & operator=(const PoolAllocator< T > &)=default
constexpr T * allocate(size_t n)
Definition Pool.hpp:128
constexpr PoolAllocator(const PoolAllocator< T > &other)=default
constexpr PoolAllocator(PoolResource *r)
Definition Pool.hpp:117
constexpr void deallocate(T *p, size_t n)
Definition Pool.hpp:138
T value_type
Definition Pool.hpp:110
void * allocate(size_t bytes, size_t alignment=alignof(std::max_align_t))
Definition Pool.hpp:42
PoolResource & operator=(const PoolResource &)=delete
PoolResource(PoolResource &&)=default
PoolResource & operator=(PoolResource &&)=default
PoolResource(size_t blocksPerChunk)
Definition Pool.hpp:27
size_t blocks_in_use() const noexcept
Definition Pool.hpp:76
void deallocate(void *p, size_t bytes, size_t alignment=alignof(std::max_align_t))
Definition Pool.hpp:60
bool is_equal(const PoolResource &other) const noexcept
Definition Pool.hpp:69
PoolResource(const PoolResource &)=delete
Definition small_vector.hpp:3616
::value &&MoveInsertable constexpr reference emplace_back(Args &&... args)
Definition small_vector.hpp:4071
constexpr reference back()
Definition small_vector.hpp:3952
Definition Expression.hpp:18
IntrusiveSharedPtr< T > AllocateIntrusiveShared(Alloc alloc, Args &&... args)
Definition IntrusiveSharedPtr.hpp:275
PoolAllocator< T > GlobalPoolAllocator()
Definition Pool.hpp:157
SLEIPNIR_DLLEXPORT PoolResource & GlobalPoolResource()