Template Struct PoolState

Inheritance Relationships

Base Types

Struct Documentation

template<typename T>
struct PoolState : public CE::Memory::AbstractBlockManager<T>, public std::enable_shared_from_this<PoolState<T>>

Owns the object pool’s release operations and retains shared block bookkeeping.

Handles hold this context so their last release can merge a slot back into the pool after the Pool<T> facade is destroyed.

Public Functions

inline std::shared_ptr<typename ::CE::Memory::Objects::Constructor<T>::Context> construction_context() const

Declaration: [[nodiscard]]

Returns:

Retained per-T construction tracker. Final owners capture it before facade teardown; it synchronizes slot transitions, not user operations on T.

template<typename ...Args>
std::vector<std::shared_ptr<T>> retrieve_objects(std::size_t N, Args... args)

Construct an independent batch and return one final owner per completed object.

Parameters:
  • N – Requested object count; zero returns an empty vector.

  • args – Stored arguments repeatedly forwarded to each constructor; moving from them can affect later elements.

Returns:

Per-slot shared handles retaining this PoolState and its construction tracker. This state must already have shared ownership (normally through Pool or an allocator); shared_from_this failure propagates. Construction/allocation failure releases completed handles and returns the unconstructed tail. Final handle release destroys its tracked object then returns exactly one slot; cleanup failure reports and terminates instead of escaping a deleter.

::CE::Memory::Block<T> retrieve_block(std::size_t N)

Check out unconstructed T slots from the per-T pool, allocating byte backing outside locks if needed.

Parameters:

N – Positive minimum slot count; zero throws bad_request.

Returns:

Block retaining its backing owner and construction/byte return contexts. Growth can provide extra slots; all lengths count T objects. Overflow or allocation failures propagate before a partial logical checkout is published.

void return_objects(T *p, std::size_t length)

Return one positive current slot subrange, merging neighboring free sections.

Parameters:
  • p – First T slot in a current checked-out range.

  • length – In-bounds slot count, not bytes; users/constructed lifetimes must already be finished.

Throws:

CE::Exceptions::bad_request – For unknown, already-pooled or out-of-bounds ranges. Bookkeeping is transactional; this operation itself does not destroy objects.

void return_block(const ::CE::Memory::Block<T> &returned)

Return exact current Block metadata to the typed free pool.

Parameters:

returned – Complete checked-out range whose users/lifetimes have ended. Unknown/already-free/invalid ranges throw failed_operation. No user destructor runs under bookkeeping locks; backing is retained for reuse/culling.

void release_owned(T *p, std::size_t length) noexcept

Return a known owned slot range from a final deleter without facade lookup.

Parameters:
  • p – First slot after object destruction is complete.

  • length – Positive number of slots released exactly once. Invalid bookkeeping or allocation/locking failure is reported and terminates; ordinary recoverable range validation belongs to return_objects().