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

SlotResidency

Struct SlotResidency 

Source
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: usize

Index of the slot holding the room being shown.

Implementations§

Source§

impl<const SLOTS: usize, const WANTED: usize> SlotResidency<SLOTS, WANTED>

Source

pub const fn new() -> Self

All slots empty, nothing wanted.

Source

pub fn find(&self, region: usize) -> Option<usize>

Slot holding the verified room region.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn claim_stored(&mut self, i: usize) -> usize

Hand stored slot i to a decoder: it becomes loading again. Returns the region.

Source

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.

Source

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.

Source

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.

Source

pub fn is_loading(&self, region: usize) -> bool

Whether region is being read or decoded.

Source

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.

Source

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.

Source

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.

Source

pub fn can_reserve(&self, region: usize, urgent: bool) -> bool

Whether SlotResidency::reserve would succeed.

Source

pub fn reserve(&mut self, region: usize, urgent: bool) -> Option<usize>

Take a slot for reading region (its previous contents are dropped). urgent lets the read displace wishlist entries.

Source

pub fn admit(&mut self, i: usize, region: usize, len: usize)

Slot i now holds the verified room region of len bytes.

Trait Implementations§

Source§

impl<const SLOTS: usize, const WANTED: usize> Default for SlotResidency<SLOTS, WANTED>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<const SLOTS: usize, const WANTED: usize> Freeze for SlotResidency<SLOTS, WANTED>

§

impl<const SLOTS: usize, const WANTED: usize> RefUnwindSafe for SlotResidency<SLOTS, WANTED>

§

impl<const SLOTS: usize, const WANTED: usize> Send for SlotResidency<SLOTS, WANTED>

§

impl<const SLOTS: usize, const WANTED: usize> Sync for SlotResidency<SLOTS, WANTED>

§

impl<const SLOTS: usize, const WANTED: usize> Unpin for SlotResidency<SLOTS, WANTED>

§

impl<const SLOTS: usize, const WANTED: usize> UnsafeUnpin for SlotResidency<SLOTS, WANTED>

§

impl<const SLOTS: usize, const WANTED: usize> UnwindSafe for SlotResidency<SLOTS, WANTED>

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.