4#ifndef IT_D4NP_MEMORYPOOL_MEMORY_POOL_HPP_
5#define IT_D4NP_MEMORYPOOL_MEMORY_POOL_HPP_
26namespace it::d4np::memorypool {
85 [[nodiscard]]
static std::optional<Pool>
make(std::size_t
block_size, std::size_t block_count);
101 std::size_t growth_factor);
107 Pool& operator=(const
Pool&) = delete;
236 [[nodiscard]] std::optional<Pool>
build()
const;
239 std::size_t block_size_ = 0;
240 std::size_t block_count_ = 0;
241 std::size_t growth_factor_ = 0;
Fluent builder for configured Pool instances.
PoolBuilder & with_block_size(std::size_t block_size) noexcept
Set the per-block size in bytes; must satisfy ADR-0009 §2 at build time.
PoolBuilder & with_block_count(std::size_t block_count) noexcept
Set the block count; must satisfy ADR-0009 §3 at build time.
PoolBuilder & with_growth_factor(std::size_t growth_factor) noexcept
Opt into dynamic growth with the given geometric factor (ADR-0024 §3).
std::optional< Pool > build() const
Produce a std::optional<Pool> from the accumulated configuration.
Owning, non-copyable, move-only wrapper around a memory_pool_t*.
void deallocate(void *block) noexcept
Return a previously allocated block to the pool in O(1).
void * allocate()
Allocate one block in O(1) — throwing verb (ADR-0016 §2).
std::size_t block_size() const noexcept
Report the configured per-block size in bytes (ADR-0018 §3).
memory_pool_t * native_handle() noexcept
void * try_allocate() noexcept
Allocate one block in O(1) — non-throwing verb (ADR-0016 §2).
static std::optional< Pool > make_dynamic(std::size_t block_size, std::size_t block_count, std::size_t growth_factor)
Factory function for a dynamic-growth pool (spec §2.2, ADR-0022 / ADR-0024): on exhaustion it acquire...
std::size_t metadata_bytes() const noexcept
Report the per-pool metadata overhead in bytes (spec §3.2 / ADR-0015).
Pool(std::size_t block_size, std::size_t block_count)
Construct a pool with block_count blocks of block_size bytes each.
static std::optional< Pool > make(std::size_t block_size, std::size_t block_count)
Factory function returning an engaged std::optional<Pool> on successful construction or std::nullopt ...
~Pool() noexcept
Destroy the pool, releasing all backing storage to the OS.
Public C API for the pbr-cpp-memory-pool fixed-block-size allocator.
struct memory_pool memory_pool_t
Opaque handle to a memory pool instance.