implements PLN-0127 async io lane boundaries
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use crate::fs::{FsError, VirtualFS};
|
||||
use crate::services::async_work::{AsyncWorkJobKind, AsyncWorkPriority};
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub const MEMCARD_SLOT_COUNT: usize = 32;
|
||||
@@ -50,6 +51,30 @@ pub struct MemcardWriteResult {
|
||||
pub bytes_written: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum MemcardAsyncLaneOperation {
|
||||
SlotWrite,
|
||||
SlotCommit,
|
||||
SlotClear,
|
||||
SlotRead,
|
||||
SlotStat,
|
||||
}
|
||||
|
||||
impl MemcardAsyncLaneOperation {
|
||||
pub const fn job_kind(self) -> AsyncWorkJobKind {
|
||||
AsyncWorkJobKind::Memcard
|
||||
}
|
||||
|
||||
pub const fn priority(self) -> AsyncWorkPriority {
|
||||
match self {
|
||||
Self::SlotWrite | Self::SlotCommit | Self::SlotClear => {
|
||||
AsyncWorkPriority::MemcardCommitWrite
|
||||
}
|
||||
Self::SlotRead | Self::SlotStat => AsyncWorkPriority::NonCriticalReadList,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct SlotImage {
|
||||
payload: Vec<u8>,
|
||||
@@ -428,4 +453,29 @@ mod tests {
|
||||
let stat = mem.slot_stat(&fs, 7, 2);
|
||||
assert_eq!(stat.state, MemcardSlotState::Corrupt);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn memcard_async_lane_operations_classify_priority_without_changing_public_api() {
|
||||
assert_eq!(MemcardAsyncLaneOperation::SlotWrite.job_kind(), AsyncWorkJobKind::Memcard);
|
||||
assert_eq!(
|
||||
MemcardAsyncLaneOperation::SlotWrite.priority(),
|
||||
AsyncWorkPriority::MemcardCommitWrite
|
||||
);
|
||||
assert_eq!(
|
||||
MemcardAsyncLaneOperation::SlotCommit.priority(),
|
||||
AsyncWorkPriority::MemcardCommitWrite
|
||||
);
|
||||
assert_eq!(
|
||||
MemcardAsyncLaneOperation::SlotClear.priority(),
|
||||
AsyncWorkPriority::MemcardCommitWrite
|
||||
);
|
||||
assert_eq!(
|
||||
MemcardAsyncLaneOperation::SlotRead.priority(),
|
||||
AsyncWorkPriority::NonCriticalReadList
|
||||
);
|
||||
assert_eq!(
|
||||
MemcardAsyncLaneOperation::SlotStat.priority(),
|
||||
AsyncWorkPriority::NonCriticalReadList
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user