pbr-cpp-memory-pool 1.1.2
Fixed-block-size O(1) memory pool — C++17 with an ANSI C public surface
Loading...
Searching...
No Matches
instrumented_pool.hpp File Reference

Instrumented pool variant — the Decorator pattern (ADR-0025). More...

#include <it/d4np/memorypool/memory_pool.hpp>
#include <atomic>
#include <cstddef>
#include <cstdint>
#include <new>
#include <optional>
#include <ostream>
#include <utility>
#include <vector>

Go to the source code of this file.

Classes

struct  it::d4np::memorypool::PoolStats
 Copyable snapshot of an InstrumentedPool's counters (ADR-0025 §2). More...
 
struct  it::d4np::memorypool::PoolObserver
 Observer of pool-lifecycle events (the GoF Observer — ADR-0026). More...
 
class  it::d4np::memorypool::InstrumentedPool
 Move-only Decorator over Pool that instruments allocation activity. More...
 

Enumerations

enum class  it::d4np::memorypool::PoolEvent : std::uint8_t { exhausted , grew , destroyed }
 Pool lifecycle events delivered to observers (ADR-0026). More...
 

Detailed Description

Instrumented pool variant — the Decorator pattern (ADR-0025).

InstrumentedPool composes a Pool (ADR-0010) and re-exposes its surface, counting allocations / deallocations / failures and tracking the live-block high-water mark. It is the Decorator in its idiomatic-C++ (composition) form: Pool is a concrete, move-only value type with no virtual surface, so the decorator wraps it rather than inheriting (as TypedPool / PoolAllocator do — ADR-0017 / ADR-0018).

Instrumentation is opt-in by type: a program that uses Pool directly pays nothing (no counter, no branch, no atomic) — the ROADMAP §6 zero-overhead goal holds by construction (verified in M6.3). The counters are relaxed atomics, so the decorator is safe to wrap a thread-safe (MUTEX/LOCKFREE) pool and drive it concurrently; under contention the live/peak high-water mark is an approximate, eventually-consistent diagnostic.

Header-only; adds zero object code and zero per-pool metadata to the library. Per-event lifecycle notification (exhaustion / growth / destruction) is the Observer pattern added in M6.2, not here.

Definition in file instrumented_pool.hpp.

Enumeration Type Documentation

◆ PoolEvent

enum class it::d4np::memorypool::PoolEvent : std::uint8_t
strong

Pool lifecycle events delivered to observers (ADR-0026).

Enumerator
exhausted 

an allocation found the pool exhausted (returned NULL / threw)

grew 

the (dynamic) pool acquired an overflow chunk

destroyed 

the instrumented pool is being destroyed

Definition at line 58 of file instrumented_pool.hpp.