Appearance
class flake::PropertyPool
Shared, bounded Property storage with shift-compaction. More...
#include <platform/flake/PropertyPool.hpp>
Public Classes
| Name | |
|---|---|
| struct | Stats |
Public Functions
| Name | |
|---|---|
| bool | registerInstance(PropArrayHandle * h) Register a PropArray handle. |
| void | unregisterInstance(PropArrayHandle * h) Unregister a handle, freeing every slot it owns and resetting h. Safe to call on an already-cleared handle. |
| bool | pushBack(PropArrayHandle * h, const Property & p) Append p to the owner's slice. |
| bool | insertAt(PropArrayHandle * h, uint16_t localIdx, const Property & p) Insert p at owner-local index localIdx. |
| void | eraseAt(PropArrayHandle * h, uint16_t localIdx) Erase the owner's slot at localIdx. localIdx``>=``h->count is a no-op. |
| void | clearOwner(PropArrayHandle * h) Erase every slot owned by the handle. h->count becomes 0; the handle stays registered. |
| Property & | slotOf(const PropArrayHandle * h, uint16_t localIdx) O(1) mutable access to the handle's slot at localIdx. The reference is stable only until the next pool mutation. |
| const Property & | slotConstOf(const PropArrayHandle * h, uint16_t localIdx) Const variant of slotOf. |
| Stats | stats() Sample pool statistics (for tests and diagnostics). |
| int | carve(Arena & arena) Bind the pool's storage to slices of arena. |
| PropertyPool() =deleted |
Detailed Description
cpp
class flake::PropertyPool;Shared, bounded Property storage with shift-compaction.
Par:
- Pointer stability
[Property](/embed/2.2.0/API/Classes/classflake_1_1Property.md) addresses handed out via slotOf / slotConstOf are valid only until the next mutating call on anyPropArray in the pool. That is a strictly stronger contract than std::vector: a mutation on PropArray A may relocate the sequence entries of PropArray B. Callers that want reference-stability across mutations must copy.
- Thread-safety
Every mutating entry point serialises on an internal spinlock. Like std::vector, concurrent reads on one PropArray and writes on another are unsynchronised at the reference level — callers provide that synchronisation.
- Exhaustion
Mutating methods that can grow the occupied storage return bool. false means the pool is full (no free storage slot or no free sequence position). Public-API methods map that to E_NO_ALLOC.
All state is zero-initialised in BSS. The pool is usable from the first moment any client code runs; no explicit flakeInitialize call is required.
Public Functions Documentation
function registerInstance
cpp
static bool registerInstance(
PropArrayHandle * h
)Register a PropArray handle.
On success sets h->id, h->seqOffset, h->count and returns true. Returns false on registry exhaustion. The handle address must remain valid until unregisterInstance is called.
function unregisterInstance
cpp
static void unregisterInstance(
PropArrayHandle * h
)Unregister a handle, freeing every slot it owns and resetting h. Safe to call on an already-cleared handle.
function pushBack
cpp
static bool pushBack(
PropArrayHandle * h,
const Property & p
)Append p to the owner's slice.
Return: false on pool exhaustion.
function insertAt
cpp
static bool insertAt(
PropArrayHandle * h,
uint16_t localIdx,
const Property & p
)Insert p at owner-local index localIdx.
Parameters:
- localIdx must satisfy
localIdx``<=``h->count.
Return: false on pool exhaustion or out-of-range index.
function eraseAt
cpp
static void eraseAt(
PropArrayHandle * h,
uint16_t localIdx
)Erase the owner's slot at localIdx. localIdx``>=``h->count is a no-op.
function clearOwner
cpp
static void clearOwner(
PropArrayHandle * h
)Erase every slot owned by the handle. h->count becomes 0; the handle stays registered.
function slotOf
cpp
static Property & slotOf(
const PropArrayHandle * h,
uint16_t localIdx
)O(1) mutable access to the handle's slot at localIdx. The reference is stable only until the next pool mutation.
function slotConstOf
cpp
static const Property & slotConstOf(
const PropArrayHandle * h,
uint16_t localIdx
)Const variant of slotOf.
function stats
cpp
static Stats stats()Sample pool statistics (for tests and diagnostics).
function carve
cpp
static int carve(
Arena & arena
)Bind the pool's storage to slices of arena.
Called from flakeArenaCarveAllPools at flakeInitialize* time. In default mode (FLAKE_EXTERNAL_ARENA=OFF) the pool's arrays already live in BSS and this is a no-op. In external- arena mode, the arrays are nullptr until this carves them out of the arena. Idempotent across multiple calls in the same process. Returns 0 on success, -1 on arena exhaustion.
function PropertyPool
cpp
PropertyPool() =deleted