Template Struct BlockTransactions

Struct Documentation

template<typename T>
struct BlockTransactions

Transactions over one retained CE::Memory::BlockManagement<T>::State.

All five collections are locked together. Replacement nodes are allocated before existing records change, then transferred with the same allocator and nonthrowing comparators. Backing allocation and final owner destruction happen outside these locks. Direct collection access still requires external quiescence and the same invariants. Included by block.h after its CE::Memory::Block hash specialization.

Public Types

using BlockType = ::CE::Memory::Block<T>

Range metadata; lengths count T objects, or bytes for void.

using State = typename ::CE::Memory::BlockManagement<T>::State

Shared per-T collections retained independently of manager facades.

using Pool = std::set<BlockType, ::CE::Memory::Ordering::PoolOrder<T>>

Reusable free-range collection, ordered by checkout suitability.

using Sections = std::set<BlockType, ::CE::Memory::Ordering::HeadOrder<T>>

Address-ordered partition sections for split backing allocations.

using Registry = std::set<BlockType, ::CE::Memory::Ordering::RegistryOrder<T>>

Complete backing-allocation metadata retaining underlying owners.

using Stale = std::unordered_map<BlockType, typename ::CE::Memory::BlockManagement<T>::tpoint>

Timestamps of complete free owners; not timestamps for every free section.

Public Functions

inline ::CE::Memory::OptionalBlock<T> return_block(const std::shared_ptr<State> &state, const BlockType &block)

Return an exact current checked-out range and coalesce adjacent free sections.

Parameters:
  • state – Nonnull retained bookkeeping domain matching the range.

  • block – Valid owner/head/alignment/length; all users and live-object obligations must already be finished.

Returns:

Merged free range, or nullopt for unknown, zero, already-free or inconsistent range metadata. Replacement-node allocation occurs before partition mutation; failures propagate without partial logical change. Returning a whole owner starts its stale age, but does not immediately free backing or destroy T.

inline ::CE::Memory::OptionalBlock<T> return_range(const std::shared_ptr<State> &state, T *ptr, std::optional<std::size_t> count)

Return a current containing range or an exact element-aligned subrange.

Parameters:
  • state – Nonnull matching per-T domain.

  • ptr – Address in a checked-out section or complete owner.

  • count – Positive in-bounds element count; nullopt returns the whole containing section, not only its suffix.

Returns:

Merged returned range, or nullopt for absent, pooled, misaligned or invalid bounds. No constructed-object tracking/destruction occurs; stop users and end object lifetimes first. Collection locks protect transactional partitioning, not accesses to storage.

inline ::CE::Memory::OptionalBlock<T> find_section(const std::shared_ptr<State> &state, T *ptr)

Copy split-section metadata containing an address under the section read lock.

Parameters:
  • state – Nonnull retained domain.

  • ptr – Candidate address in valid representable backing storage.

Returns:

Retained containing range, or nullopt. This observation is not a checkout/live-object guarantee and cannot replace a compound transaction.

inline ::CE::Memory::OptionalBlock<T> find_owner(const std::shared_ptr<State> &state, T *ptr)

Copy complete backing-owner metadata containing an address under the registry read lock.

Parameters:
  • state – Nonnull retained domain.

  • ptr – Candidate address.

Returns:

Retained owner metadata, or nullopt; it does not prove a currently constructed or exclusively owned object.

inline ::CE::Memory::OptionalBlock<T> fill_request(const std::shared_ptr<State> &state, std::size_t count, std::align_val_t alignment)

Claim the first whole free range meeting count/alignment without splitting or allocating backing.

Parameters:
  • state – Nonnull per-T domain.

  • count – Positive minimum element/byte count supplied by the caller.

  • alignment – Required valid byte alignment.

Returns:

Claimed whole range or nullopt when none fits. Removes matching pool/stale/release records atomically; no user T construction occurs.

Public Static Functions

template<typename Allocate>
static inline BlockType checkout(const std::shared_ptr<State> &state, std::size_t count, std::align_val_t alignment, Allocate allocate)

Claim/split one compatible free range, allocating backing outside all collection locks when needed.

Template Parameters:

Allocate – Callable returning a complete valid owned Block<T> with sufficient count/alignment.

Parameters:
  • state – Nonnull retained per-T bookkeeping state.

  • count – Positive representable element count, or bytes for void; callers validate policy/overflow before this primitive.

  • alignment – Nonzero valid requested byte alignment.

  • allocate – Synchronous fallback invoked outside locks; its returned owner survives rollback until locks release.

Returns:

Checked-out head range, possibly enlarged for an aligned void tail. All five collections commit together after replacement-node allocation succeeds. Concurrent returns may satisfy the request after backing allocation; unused fresh backing is released outside locks. Allocation/user-callback failures propagate without a partially published partition; no T object is constructed.

static inline void register_free(const std::shared_ptr<State> &state, const BlockType &block)

Register one fresh complete backing owner as immediately reusable and stale.

Parameters:
  • state – Nonnull per-T domain.

  • block – New complete owned allocation with valid representable count/alignment; it must not overlap an existing registration. Builds replacement records before coordinated publication. Allocation failure leaves live collections unchanged; final backing release stays outside locks. Caller retains responsibility for valid metadata and nonoverlap.

static inline void record_new(const std::shared_ptr<State> &state, const BlockType &block)

Record only a complete backing owner in the registry under its write lock.

Parameters:
  • state – Nonnull per-T domain.

  • block – Valid owned allocation; this primitive does not add it to pool/stale/sections. Allocation failure propagates. Callers using this low-level operation maintain the surrounding multi-collection invariants.

static inline void mark_stale(const std::shared_ptr<State> &state, const BlockType &block)

Timestamp an exact complete free owner if no stale record exists.

Parameters:
  • state – Nonnull per-T domain.

  • block – Complete owner present in both registry and pool; other metadata is ignored. All collections are locked for validation; an existing timestamp is preserved rather than refreshing its age. Allocation failure propagates before a new stale record is visible.

static inline void cull(const std::shared_ptr<State> &state, std::chrono::minutes age)

Move sufficiently old whole-free-owner stale records to the pending-release set.

Parameters:
  • state – Nonnull domain; callers retain it through the operation.

  • age – Minimum monotonic stale duration; negative age makes current stale entries eligible. Preparation allocations precede record removal. This queues retirement only; release_culled() rechecks current registry/pool/partition state before freeing backing.

static inline void release_culled(const std::shared_ptr<State> &state)

Remove queued owners only while still complete and free, then release final backing outside every collection lock.

Parameters:

state – Nonnull retained per-T domain. Checked-out/split owners are not forcibly released; pending records are drained after the eligibility pass. Final owner cleanup may destroy tracked T objects or return byte backing, so user destruction never runs while bookkeeping locks are held. Caller must preserve valid domain invariants.