ComponentCacheBase class
Non-template concrete base for all SoA ring-buffer caches.
Owns all slab memory, frame headers, field allocation tables, and the frame locking protocol. Archetype, LogicThread, and RenderThread all store a ComponentCacheBase* so they are decoupled from the tier template.
No virtual functions — Initialize is on the CRTP middle layer; all runtime methods here are concrete and shared between Volatile and Temporal tiers.
Derived classes
-
template<typename Derived>class ComponentCacheImpl
- CRTP middle layer that routes
Initialize()to tier-specific overrides. -
template<typename Derived>class ComponentCacheImpl
- CRTP middle layer that routes
Initialize()to tier-specific overrides.
Public types
- struct FieldCompareInfo
Constructors, destructors, conversion operators
Public functions
- auto GetFrameHeader(int32_t frameNum = -1) const -> TemporalFrameHeader*
- O(1) frame header access. External systems are responsible for locking.
- auto TryLockFrameForWrite(uint32_t& outWriteFrame) -> bool
- Try to claim the next write slot. After propagation the frame remains locked until propagated again.
- auto VerifyFrameReadable(uint32_t bufferIndex) const -> bool
- void UnlockFrameWrite()
- Release the current write lock.
- auto TryLockFrameForRead(uint32_t frameNum) -> bool
- Try to acquire a shared read lock on
frameNum. - void UnlockFrameRead(uint32_t frameNum)
- Release a previously acquired read lock.
- auto GetActiveWriteFrame() const -> uint32_t
- auto GetActiveReadFrame() const -> uint32_t
- auto AllocateFieldArray(Archetype* owner, struct Chunk* chunk, CacheSlotID cacheSlot, size_t fieldIndex, const char* fieldName, size_t entityCount, size_t fieldSize, SystemID EntitySystemID) -> void*
- auto AdvanceAllocator(SystemID EntitySystemID, size_t entityCount, size_t fieldSize) -> size_t
- void ResetAllocators()
- void ClearFrameData()
- void NotifyChunkFreed(Chunk* chunk)
- auto TryReuseFreedSlab(Chunk* newChunk, Archetype* owner) -> size_t
-
auto GetFrameStride() const -> FORCE_
INLINE size_t -
auto GetWriteFramePtr(void* frame0Base) const -> FORCE_
INLINE void* -
auto GetReadFramePtr(void* frame0Base) const -> FORCE_
INLINE void* -
auto GetFramePtrAtAbsoluteFrame(void* frame0Base,
uint32_t absoluteSimFrame) const -> FORCE_
INLINE void* -
void PropagateFrameData(uint32_t fromFrame,
uint32_t toFrame,
TrinyxJobs::
JobCounter& counter) - auto GetFieldData(TemporalFrameHeader* header, CacheSlotID cacheSlot, size_t fieldIndex) const -> void*
- auto GetTotalFrameCount() const -> uint32_t
- auto GetTier() const -> CacheTier
- auto GetMaxCachedEntityCount() const -> uint32_t
- auto GetPhysicsRange() const -> std::pair<uint32_t, uint32_t>
- auto GetSystemAllocatorIndex(SystemID sysID, size_t size) const -> size_t
- auto AdvanceSystemAllocatorIndex(SystemID sysID, size_t size) -> size_t
- auto GetNextWriteFrame() const -> uint32_t
-
void PropagateFrame(TrinyxJobs::
JobCounter& counter) -
void PropagateFrameResim(TrinyxJobs::
JobCounter& counter) - void SetActiveWriteFrame(uint32_t frame)
- void SetLastWrittenFrame(uint32_t frame)
- auto GetSlabPtr() const -> void*
- auto GetTotalSlabSize() const -> size_t
- auto GetFrameDataCapacity() const -> size_t
- auto GetValidFieldInfos() const -> std::vector<FieldCompareInfo>
Protected functions
- void InitializeInternal(const EngineConfig* Config, uint32_t frameCount)
- auto LockFrameForWrite(uint32_t WriteFrame) -> bool
Protected variables
- FnGetNextWriteFramePtr FnGetNextWriteFrame
- FnPropagateFramePtr FnPropagateFrame
- CacheTier Tier_
- uint32_t LastWrittenFrame
- uint32_t ActiveWriteFrame
- size_t MaxRenderableBoundary
- size_t MaxCachedBoundary
- size_t RenderOffset
- size_t DualOffset
- size_t PhysOffset
- size_t LogicOffset
Function documentation
TemporalFrameHeader* ComponentCacheBase:: GetFrameHeader(int32_t frameNum = -1) const
O(1) frame header access. External systems are responsible for locking.
| Parameters | |
|---|---|
| frameNum | Ring-buffer slot index; -1 returns the active write frame. |
bool ComponentCacheBase:: TryLockFrameForWrite(uint32_t& outWriteFrame)
Try to claim the next write slot. After propagation the frame remains locked until propagated again.
| Parameters | |
|---|---|
| outWriteFrame out | The slot index being written to (for field data access). |
bool ComponentCacheBase:: VerifyFrameReadable(uint32_t bufferIndex) const
| Returns | true if no writer holds bufferIndex. |
|---|