Template Class Reservation

Class Documentation

template<typename T, typename Allocator = ::CE::Memory::Allocators::ObjectPoolAllocator<T>>
class Reservation

Requires: ReservationAllocator<Allocator, T>

Reserves one CE::Memory::Block and tracks only its unclaimed ranges.

emplace() splits out a slot and gives its handle the release context; the handle may outlive this reservation. Failed construction leaves the slot reserved, while the destructor returns remaining contiguous ranges to the manager. Move construction transfers the reservation; copying and both assignment forms are deleted.

Public Functions

inline explicit Reservation(std::size_t count, Allocator allocator = {})

Reserve unconstructed storage and retain its pool release context.

Template Parameters:
  • T – Reserved object type; its final destruction must not throw.

  • Allocator – ReservationAllocator exposing a retained context for T.

Parameters:
  • count – Logical slot count; zero creates an empty reservation without checkout.

  • allocator – Copied only to capture the retained context. Allocation/checkout errors propagate without constructing T objects. The reservation is caller-owned and unsynchronized; do not race emplace(), move or destruction.

Reservation(const Reservation&) = delete
Reservation &operator=(const Reservation&) = delete
inline Reservation(Reservation &&other) noexcept

Transfer context and unclaimed ranges, leaving other empty with size zero.

Previously claimed object handles remain independent; caller excludes concurrent operations.

Reservation &operator=(Reservation&&) = delete
inline ~Reservation() noexcept

Return remaining unclaimed contiguous ranges without touching already claimed objects.

Claimed handles retain the release context and may outlive this reservation/facade. Invalid final-return bookkeeping terminates under release_owned() rules; this is not a destructor for unconstructed slots.

inline const std::vector<::CE::Memory::Block<T>> &remaining_ranges() const noexcept

Declaration: [[nodiscard]]

Returns:

Borrowed unclaimed partition; emplace()/move/destruction can invalidate references/iterators or change its contents. Retain and exclusively own the reservation while inspecting it.

inline std::size_t size() const noexcept

Declaration: [[nodiscard]]

Returns:

Original logical slot count, not remaining unclaimed slots; moved-from reservations report zero.

template<typename ...Args>
inline std::shared_ptr<T> emplace(std::size_t index, Args&&... args)

Construct one unclaimed slot and transfer it to an independently retained owner.

Parameters:
  • index – Zero-based index below size(), not an index into remaining_ranges().

  • args – Perfect-forwarded constructor arguments used only for this object.

Returns:

Aliasing shared_ptr whose final release destroys T once and returns exactly one slot through the retained context. Out-of-range/already-claimed indices throw bad_request. Allocation or constructor failure leaves that slot reserved and the partition unchanged; retry is permitted. No other slot is constructed. Returned objects may outlive the reservation/pool facade; caller synchronizes object access and supplies nonthrowing destruction.