|
pbr-cpp-memory-pool 1.1.2
Fixed-block-size O(1) memory pool — C++17 with an ANSI C public surface
|
Move-only Decorator over Pool that instruments allocation activity.
More...
#include <instrumented_pool.hpp>
Public Member Functions | |
| InstrumentedPool (Pool &&pool) noexcept | |
Adopt pool by move and start instrumenting it. | |
| InstrumentedPool (const InstrumentedPool &)=delete | |
| InstrumentedPool & | operator= (const InstrumentedPool &)=delete |
| InstrumentedPool (InstrumentedPool &&other) noexcept | |
| Move-construct; the atomic counters are loaded and re-seeded (ADR-0025 §2). | |
| InstrumentedPool & | operator= (InstrumentedPool &&other) noexcept |
| Move-assign; releases the current pool and re-seeds the counters + observers. | |
| ~InstrumentedPool () | |
| Notify observers of destruction (ADR-0026); a moved-from instance has no observers. | |
| void | add_observer (PoolObserver &observer) |
| Register an observer of lifecycle events (ADR-0026). | |
| void * | allocate () |
| Throwing allocation verb (ADR-0016 §2). | |
| void * | try_allocate () noexcept |
| Non-throwing allocation verb (ADR-0016 §2). | |
| void | deallocate (void *block) noexcept |
| Return a block; counts the deallocation for any non-null pointer. | |
| PoolStats | stats () const noexcept |
| void | write_summary (std::ostream &os) const |
Write a one-line human-readable summary of the counters to os. | |
| memory_pool_t * | native_handle () noexcept |
| std::size_t | block_size () const noexcept |
| std::size_t | metadata_bytes () const noexcept |
Static Public Member Functions | |
| static std::optional< InstrumentedPool > | make (std::size_t block_size, std::size_t block_count) |
Factory mirroring Pool::make — std::nullopt on construction failure. | |
| static std::optional< InstrumentedPool > | make_dynamic (std::size_t block_size, std::size_t block_count, std::size_t growth_factor) |
Factory mirroring Pool::make_dynamic (ADR-0024) — std::nullopt on failure. | |
Move-only Decorator over Pool that instruments allocation activity.
Mirrors the Pool allocation surface (ADR-0016 verbs) and counts it. Copy is deleted (it owns a move-only Pool); move is hand-written because the atomic counters are not move-constructible.
Definition at line 98 of file instrumented_pool.hpp.
|
inlineexplicitnoexcept |
Adopt pool by move and start instrumenting it.
Definition at line 101 of file instrumented_pool.hpp.
|
inlinenoexcept |
Move-construct; the atomic counters are loaded and re-seeded (ADR-0025 §2).
The observer list is moved (leaving other empty, so its destructor notifies nobody).
Definition at line 128 of file instrumented_pool.hpp.
|
inline |
Notify observers of destruction (ADR-0026); a moved-from instance has no observers.
Definition at line 156 of file instrumented_pool.hpp.
|
inlinestatic |
Factory mirroring Pool::make — std::nullopt on construction failure.
Definition at line 104 of file instrumented_pool.hpp.
|
inlinestatic |
Factory mirroring Pool::make_dynamic (ADR-0024) — std::nullopt on failure.
Definition at line 114 of file instrumented_pool.hpp.
|
inlinenoexcept |
Move-assign; releases the current pool and re-seeds the counters + observers.
The pool being replaced is going away, so its observers get a destroyed event first — symmetric with the destructor (BUG-0003).
Definition at line 139 of file instrumented_pool.hpp.
|
inline |
Register an observer of lifecycle events (ADR-0026).
Must out-live this pool.
Definition at line 161 of file instrumented_pool.hpp.
|
inline |
Throwing allocation verb (ADR-0016 §2).
Counts the success, or the failure on std::bad_alloc.
Definition at line 166 of file instrumented_pool.hpp.
|
inlinenoexcept |
Non-throwing allocation verb (ADR-0016 §2).
Counts success or in-band failure.
Definition at line 181 of file instrumented_pool.hpp.
|
inlinenoexcept |
Return a block; counts the deallocation for any non-null pointer.
Definition at line 194 of file instrumented_pool.hpp.
|
inlinenoexcept |
Definition at line 209 of file instrumented_pool.hpp.
|
inline |
Write a one-line human-readable summary of the counters to os.
Definition at line 216 of file instrumented_pool.hpp.
|
inlinenoexcept |
Definition at line 224 of file instrumented_pool.hpp.
|
inlinenoexcept |
Definition at line 229 of file instrumented_pool.hpp.
|
inlinenoexcept |
Definition at line 234 of file instrumented_pool.hpp.