Skip to content

EntropyEngine::Core::HandleSlotOps

Operations for stamping, validating, and releasing handles in slot-based pools. More…

#include <HandleSlot.h>

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.
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.

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:

  1. The object is not null
  2. The object has a valid handle stamp
  3. The object’s owner matches the expected owner
  4. The object’s index matches the expected index
  5. The object’s stamped generation matches the slot’s current generation
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.

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.

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