Skip to main content
← PSoXide SDK guides and examples · SDK f2fec1c301f1 · All Cargo features enabled; check feature gates before use.

Crate psx_cache

Crate psx_cache 

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

  • V is the per-slot payload (Copy); typically a small handle/metadata.
  • N is the slot capacity (how many values can be resident at once).
  • MAX_KEY is the key space; keys are u16 in 0..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 by SlotCache::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.
SlotCache
Keyed, fixed-capacity cache with LRU eviction and pinning.
Stale
SlotCache::finish_load refused a reservation whose key no longer owns its slot.

Enums§

SlotState
Load state of a slot.