pub struct SlotResidency<const SLOTS: usize, const WANTED: usize> {
pub slots: [Slot; SLOTS],
pub current: usize,
/* private fields */
}Expand description
Residency over SLOTS arenas with a wishlist of WANTED regions (hk-psx
uses 5 and 4: the current room’s slot plus four others).
Fields§
§slots: [Slot; SLOTS]The arenas.
current: usizeIndex of the slot holding the room being shown.
Implementations§
Source§impl<const SLOTS: usize, const WANTED: usize> SlotResidency<SLOTS, WANTED>
impl<const SLOTS: usize, const WANTED: usize> SlotResidency<SLOTS, WANTED>
Sourcepub fn find_stored(&self, region: usize) -> Option<usize>
pub fn find_stored(&self, region: usize) -> Option<usize>
Slot holding completed but unverified bytes of region. A completed
CD payload is not yet a room: len == 0 is exclusively stored data;
only a private decoder may turn it into a verified resident entry.
Sourcepub fn next_decode(&self, demand: usize) -> Option<usize>
pub fn next_decode(&self, demand: usize) -> Option<usize>
The stored slot to decode next: demand if it is stored, otherwise the
highest-ranked wishlist entry that is.
Sourcepub fn next_decode_during_read(
&self,
demand: usize,
reading: usize,
) -> Option<usize>
pub fn next_decode_during_read( &self, demand: usize, reading: usize, ) -> Option<usize>
Like SlotResidency::next_decode, while a read of reading is live.
Preserves speculative read/decode overlap: only an explicit unread
urgent demand can hold the idle decoder while the transport is live.
Sourcepub fn park_completed(&mut self, i: usize, region: usize)
pub fn park_completed(&mut self, i: usize, region: usize)
Slot i finished reading region. The caller must have observed the
transport done, including its Pause retirement. This releases the IRQ
lease but does not publish or pin unverified bytes.
Sourcepub fn claim_stored(&mut self, i: usize) -> usize
pub fn claim_stored(&mut self, i: usize) -> usize
Hand stored slot i to a decoder: it becomes loading again. Returns
the region.
Sourcepub fn protect_upload(&mut self, region: Option<usize>) -> bool
pub fn protect_upload(&mut self, region: Option<usize>) -> bool
Protect the slot holding region from reuse while an upload reads it
(None clears the protection). Returns false, keeping any earlier
protection, when region is not resident.
Sourcepub fn set_wanted(&mut self, regions: &[usize])
pub fn set_wanted(&mut self, regions: &[usize])
Replace the wishlist (highest priority first). The current region,
duplicates and EMPTY are dropped; extra entries are ignored.
Sourcepub fn evict_unwanted(&mut self, keep: &[usize]) -> usize
pub fn evict_unwanted(&mut self, keep: &[usize]) -> usize
Drop completed or parked payloads outside the keep set. Current, protected and in-flight slots remain untouched. Returns how many slots were freed.
Sourcepub fn is_loading(&self, region: usize) -> bool
pub fn is_loading(&self, region: usize) -> bool
Whether region is being read or decoded.
Sourcepub fn release(&mut self, i: usize)
pub fn release(&mut self, i: usize)
Give up the loading lease on slot i (a cancelled read or a failed
decode); the slot stays empty.
Sourcepub fn next_request(&self) -> Option<usize>
pub fn next_request(&self) -> Option<usize>
The first wishlist entry that is not resident, stored or loading and has a slot it may take.
Sourcepub fn select(&mut self, region: usize) -> Option<bool>
pub fn select(&mut self, region: usize) -> Option<bool>
Make the verified room region current. Some(changed) where
changed says whether the current slot moved; None when region is
not resident.
Sourcepub fn can_reserve(&self, region: usize, urgent: bool) -> bool
pub fn can_reserve(&self, region: usize, urgent: bool) -> bool
Whether SlotResidency::reserve would succeed.