EntropyEngine::Core::HandleSlotOps
EntropyEngine::Core::HandleSlotOps
Section titled “EntropyEngine::Core::HandleSlotOps”Operations for stamping, validating, and releasing handles in slot-based pools. More…
#include <HandleSlot.h>
Public Functions
Section titled “Public Functions”| Name | |
|---|---|
| template <typename T > bool | validate(const T * obj, const void * expectedOwner, uint32_t expectedIndex, const SlotGeneration & generation) Validates an object against a slot’s current state. |
| template <typename T > void | stamp(T & obj, void * owner, uint32_t index, const SlotGeneration & generation) Stamps an EntropyObject with the slot’s identity. |
| template <typename T > void | release(T & obj, SlotGeneration & generation) Releases an object from a slot. |
| template <typename T > void | clear(T & obj) Clears an object’s handle stamp without incrementing generation. |
Detailed Description
Section titled “Detailed Description”struct EntropyEngine::Core::HandleSlotOps;Operations for stamping, validating, and releasing handles in slot-based pools.
These helper functions encapsulate the common handle lifecycle operations, ensuring consistent usage of the generation pattern across all pools.
Public Functions Documentation
Section titled “Public Functions Documentation”function validate
Section titled “function validate”template <typename T >static inline bool validate( const T * obj, const void * expectedOwner, uint32_t expectedIndex, const SlotGeneration & generation)Validates an object against a slot’s current state.
Parameters:
- obj Object to validate (may be null)
- expectedOwner Expected owner pointer (typically ‘this’ pointer of the pool)
- expectedIndex Expected slot index
- generation The slot’s generation counter
Template Parameters:
- T EntropyObject-derived type
Return: true if the object is valid for this slot
Checks that:
- The object is not null
- The object has a valid handle stamp
- The object’s owner matches the expected owner
- The object’s index matches the expected index
- The object’s stamped generation matches the slot’s current generation
function stamp
Section titled “function stamp”template <typename T >static inline void stamp( T & obj, void * owner, uint32_t index, const SlotGeneration & generation)Stamps an EntropyObject with the slot’s identity.
Parameters:
- obj Object to stamp (must derive from EntropyObject)
- owner Pool that owns this slot (typically ‘this’ pointer of the pool)
- index Slot index within the pool
- generation The slot’s generation counter
Template Parameters:
- T EntropyObject-derived type
Records the owner pointer, slot index, and current generation on the object. This establishes the object’s “handle identity” for later validation.
function release
Section titled “function release”template <typename T >static inline void release( T & obj, SlotGeneration & generation)Releases an object from a slot.
Parameters:
- obj Object to release
- generation The slot’s generation counter (will be incremented)
Template Parameters:
- T EntropyObject-derived type
Clears the object’s handle stamp and increments the slot’s generation to invalidate any stale references to this slot.
function clear
Section titled “function clear”template <typename T >static inline void clear( T & obj)Clears an object’s handle stamp without incrementing generation.
Parameters:
- obj Object to clear
Template Parameters:
- T EntropyObject-derived type
Use this when you need to clear the stamp but the slot is being reused for a new object (e.g., replacing a render target with a different format). The new object will be stamped with the same generation.
Updated on 2026-01-26 at 17:14:35 -0500