Expand description
A generic, fixed-capacity slot cache for no_std/no-heap targets (PS1).
This captures the shape shared by every residency pool in the engine (the room stream scheduler, VRAM texture slots, asset residency): a small set of slots, a dense key->slot reverse map for O(1) lookup, least-recently-used eviction, and pinning to protect the in-use working set. It owns the index (which key lives in which slot, and the slot’s load state); the caller owns the memory the value points at. Keep variable-size allocation (VRAM rectangles, CD byte ranges) in a separate allocator layer.
Vis the per-slot payload (Copy); typically a small handle/metadata.Nis the slot capacity (how many values can be resident at once).MAX_KEYis the key space; keys areu16in0..MAX_KEY, used to index the reverse map. Pick the smallest bound that covers your id space.
Slots move Empty -> Loading -> Ready. Synchronous consumers use
SlotCache::get_or_insert_with; consumers whose creation is asynchronous
(streaming a room off the CD over several frames) use SlotCache::begin_load
then SlotCache::finish_load when the load completes.
Structs§
- Reservation
- A slot reserved for a key by
SlotCache::begin_load, to be completed bySlotCache::finish_load. It remembers the key as well as the slot, so a load that finishes after its slot was evicted and reused is refused instead of storing its value under another key. - Slot
Cache - Keyed, fixed-capacity cache with LRU eviction and pinning.
- Stale
SlotCache::finish_loadrefused a reservation whose key no longer owns its slot.
Enums§
- Slot
State - Load state of a slot.