3.3 KiB
3.3 KiB
Containers Pool Lease Lifetimes, Budgets, and Non-Spinning Rings
Task ID: M-CONTAINERS-02, M-CONTAINERS-03 Phase: P1 Status: APPROVED Contracts: C-01, C-04, C-05
1. Context and baseline
include/Void/Containers/Pool.hpp (ObjectPool, FixedPool) and BufferPool.hpp currently hold raw pool pointers in returned leases/deleters, leak slots on throwing construction, allocate heap nodes on buffer recycle, and lack admission/byte ceilings. include/Void/Containers/Ring.hpp currently spins indefinitely in MpscRing::pop() while waiting for ready_[tail] and lacks destruction of queued items on ring drop and explicit close()/try_pop() polling states.
2. Deliverables
src/Containers/module.cmakedeclaringINTERNAL_DEPS Core Memory.- Upgraded
include/Void/Containers/Pool.hpp: stationarystd::shared_ptr<State>,std::pmr::memory_resource*slab allocation, intrusive zero-allocnoexceptSlotrecycling, throwing-ctor rollback,ObjectPoolLimits,PoolError,try_acquire,live(),allocated_bytes(), and exception-safeFixedPool::try_acquire. - Upgraded
include/Void/Containers/BufferPool.hpp: stationarystd::shared_ptr<State>, O(1) power-of-two intrusive buckets (buckets[65]), checkedsize_classoverflow,Limits,BufferPoolError,try_acquire, extendedStats, safe pool move/destruction while leases outlive owner. - Upgraded
include/Void/Containers/Ring.hpp:PushStatus,PopStatus,PopResult<T>, Vyukov per-slot sequenceMpscRingnon-spinningtry_pop()/close(), destructor cleanup in~SpscRing()/~MpscRing(), keeping 1.xpush/pop/empty/full/capacity. - Expanded tests in
tests/standalone/Containers/{Pool,BufferPool,Ring}.cpp.
3. Exact files and interfaces
src/Containers/module.cmakeinclude/Void/Containers/Pool.hppinclude/Void/Containers/BufferPool.hppinclude/Void/Containers/Ring.hpptests/standalone/Containers/{Pool,BufferPool,Ring}.cpp
4. Edge cases
- Owner moved/destroyed while leases/buffers are still live (
~Buffer/~Ptrfrees directly viaStateand upstream resource with zero UAF and zero recycle heap allocations). std::construct_atthrowing rolls back slot/budget accounting.- Delayed MPSC producer paused inside move construction causes consumer
try_pop()to returnPopStatus::pendingwithout blocking/spinning, thenPopStatus::okonce producer completes. > 4 * Nring wraparound,close(), and~SpscRing()/~MpscRing()item destruction verified under TSan and ASan/UBSan.
5. Acceptance criteria
Pool*,BufferPool*, andRing*pass under-DVOID_WARNINGS_AS_ERRORS=ONand under Debug TSan (-DVOID_ENABLE_TSAN=ON).
6. Verification commands
dev cpp-gcc -c bash -lc 'cmake -S . -B /tmp/void-p1-containers -G Ninja -DVOID_ENABLED_MODULES="Containers;Testing" -DVOID_WARNINGS_AS_ERRORS=ON && cmake --build /tmp/void-p1-containers && /tmp/void-p1-containers/tests/VoidTests --filter "Pool*|BufferPool*|Ring*" && ctest --test-dir /tmp/void-p1-containers --output-on-failure --timeout 60'
dev cpp-gcc -c bash -lc 'cmake -S . -B /tmp/void-p1-containers-tsan -G Ninja -DCMAKE_BUILD_TYPE=Debug -DVOID_ENABLED_MODULES="Containers;Testing" -DVOID_ENABLE_TSAN=ON -DVOID_WARNINGS_AS_ERRORS=ON && cmake --build /tmp/void-p1-containers-tsan && /tmp/void-p1-containers-tsan/tests/VoidTests --filter "Ring*"'