Template Struct Manager

Inheritance Relationships

Base Types

Struct Documentation

template<double growth_factor_ = 1.6, int32_t growth_base_ = 256>
struct Manager : public CE::Memory::AbstractBlockManager<void>, public CE::State::Singleton<Manager<1.6, 256>>

Recycles byte ranges, aligning/growing a request before checkout and tracking owners, sections, and pooled remainders through CE::Memory::AbstractBlockManager<void>.

Public operations serialize bookkeeping transitions across all collections; backing allocation, final frees, and reporting run outside those locks. Concurrent operations require a live facade or a previously retained release context. This does not synchronize user access to checked-out bytes or make raw collection edits safe.

Public Types

using release_context_type = ::CE::Memory::ByteReleaseContext

Retained return interface that may outlive this facade.

Public Functions

Manager() = default

Create a live byte-manager facade and retained release context over shared void bookkeeping.

Template Parameters:
  • growth_factor_ – Positive default multiplier used only by greedy growth.

  • growth_base_ – Nonnegative default added-byte allowance. No backing allocation occurs until checkout/preallocation. Different growth-policy specializations share the same byte domain.

inline ~Manager() override

Expire the legacy facade liveness token.

Previously captured byte release contexts continue to return retained ranges without dereferencing this facade; quiesce direct facade callers before destruction.

inline std::weak_ptr<void> lifetime_token() const

Declaration: [[nodiscard]]

Returns:

Weak legacy liveness observation; it neither pins this facade nor synchronizes concurrent teardown. Capture only while the facade is live.

inline std::shared_ptr<release_context_type> release_context() const

Declaration: [[nodiscard]]

Returns:

Retained shared byte-domain return context; capture while this facade lives, then final returns may outlive it. No user-byte synchronization is implied.

std::string stats()

Declaration: [[nodiscard]]

Format an owned human-readable shared-byte-domain snapshot.

Returns:

Allocation/range/available-byte text; free percentage is n/a with no recorded bytes. Formatting/allocation errors propagate; this is not a residency limit or allocation request.

::CE::Memory::Stats diagnostics() const

Declaration: [[nodiscard]]

Copy shared byte-domain counts under coordinated collection read locks.

Returns:

Consistent backing/pool/section/release counters; no native calls or logging.

void report_diagnostics() const noexcept

Emit an optional DEBUG observation after obtaining a synchronized snapshot.

The host chooses sampling frequency; disabled logging may avoid sampling. No bookkeeping locks are held while formatting or invoking the logger.

std::string debug_info()

Declaration: [[nodiscard]]

Copy reusable ranges under the pool read lock, then format outside it.

Returns:

Owned range listing; no direct references to mutable collections escape. Snapshot/formatting allocation failures propagate.

void return_ptr(void *ptr)

Return the complete checked-out section containing an address.

Parameters:

ptr – Address in a known checked-out section/owner; this compatibility operation ignores an unknown or already-pooled result. It returns the whole containing range, not just bytes after ptr. Stop all users first; no T destruction, facade teardown or immediate native free occurs.

void return_portion(void *ptr, std::size_t length)

Return exactly a byte subrange beginning at ptr, preserving remaining checked-out sections.

Parameters:
  • ptr – First byte of the returned range within a current checked-out section.

  • length – Positive in-bounds byte count, not an object count.

Throws:

CE::Exceptions::bad_request – For unknown, pooled or out-of-bounds ranges. Stop all users of returned bytes before calling. Transaction allocation/locking failures propagate without a partially committed logical partition.

void return_chunk(const ::CE::Memory::HeapBlock &returned)

Return an exact current byte Block through the retained release context.

Parameters:

returned – Known checked-out owner/head/length metadata; aliases must no longer use its bytes. Invalid/double returns throw failed_operation; pooled backing remains retained until culling releases complete owners. This does not construct/destroy objects.

::CE::Memory::HeapBlock checkout_chunk(size_t length, size_t alignment = 0, ::CE::Memory::FitPolicy fit = ::CE::Memory::exact, size_t growth_base = growth_base_, double growth_factor = growth_factor_)

Declaration: [[nodiscard]]

Obtain a checked-out byte range by reusing shared pool storage or allocating backing outside locks.

Parameters:
  • length – Positive minimum bytes before fit-policy growth.

  • alignment – Requested byte alignment, rounded to a power of two of at least 64; zero selects that minimum.

  • fit – exact retains length, larger adds growth_base, greedy truncates growth_factor*length then adds growth_base.

  • growth_base – Added bytes for larger/greedy policies.

  • growth_factor – Finite positive greedy multiplier with representable nonshrinking result.

Returns:

Owned byte-range metadata, possibly larger due to aligned tail partitioning; storage remains unconstructed. Invalid/overflowing requests throw bad_request; allocation failures propagate. Bookkeeping commits transactionally, but user access to checked-out bytes is unsynchronized.

void preallocate(size_t blocks, size_t width, size_t gb = growth_base_, double gf = growth_factor_, std::align_val_t alignment = std::align_val_t{64})

Add reusable backing allocations without checking them out to a caller.

Parameters:
  • blocks – Number of independent allocations; zero adds none after validating width/alignment.

  • width – Positive base width in bytes.

  • gb – Added bytes after greedy growth, independent of the number of blocks.

  • gf – Finite positive multiplier yielding representable length at least width.

  • alignment – Nonzero representable byte alignment, rounded upward to a power of two. Invalid growth/size/alignment throws bad_request. A later allocation failure leaves earlier complete owners registered and eligible for ordinary culling; there is no multi-block rollback. Reporting occurs after transaction locks release.