pub struct StorageIOScheduler { /* private fields */ }Expand description
I/O request scheduler with deadline-aware, priority-based ordering.
§Ordering rules
- Requests whose
deadline_tickis at or before the current tick are dispatched first (earliest deadline first). - Among non-deadline-urgent requests, higher
IOPrioritywins. - Ties within the same priority level are broken by enqueue order (FIFO).
Implementations§
Source§impl StorageIOScheduler
impl StorageIOScheduler
Sourcepub fn new(config: SchedulerConfig) -> Self
pub fn new(config: SchedulerConfig) -> Self
Create a new scheduler with the given configuration.
Sourcepub fn submit(
&mut self,
block_cid: &str,
direction: IODirection,
priority: IOPriority,
size_bytes: u64,
deadline_tick: Option<u64>,
) -> Result<u64, String>
pub fn submit( &mut self, block_cid: &str, direction: IODirection, priority: IOPriority, size_bytes: u64, deadline_tick: Option<u64>, ) -> Result<u64, String>
Submit a new I/O request.
Returns the unique request ID on success, or an error if the pending queue is at capacity.
Sourcepub fn next_request(&mut self) -> Option<IORequest>
pub fn next_request(&mut self) -> Option<IORequest>
Pop and return the highest-priority pending request.
Ordering:
- Deadline-urgent requests (deadline ≤ current tick) come first, ordered by earliest deadline, then FIFO.
- Non-urgent requests follow, ordered by priority desc then FIFO.
Sourcepub fn complete(
&mut self,
request_id: u64,
direction: IODirection,
size_bytes: u64,
)
pub fn complete( &mut self, request_id: u64, direction: IODirection, size_bytes: u64, )
Record the completion of a previously dispatched request.
Updates internal counters for reads, writes, and bytes scheduled.
Sourcepub fn cancel(&mut self, request_id: u64) -> bool
pub fn cancel(&mut self, request_id: u64) -> bool
Cancel a pending request by ID.
Returns true if the request was found and removed.
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
Number of requests currently pending dispatch.
Sourcepub fn pending_reads(&self) -> usize
pub fn pending_reads(&self) -> usize
Number of pending read requests.
Sourcepub fn pending_writes(&self) -> usize
pub fn pending_writes(&self) -> usize
Number of pending write requests.
Sourcepub fn current_tick(&self) -> u64
pub fn current_tick(&self) -> u64
Return the current tick value.
Sourcepub fn expired_requests(&self) -> Vec<&IORequest>
pub fn expired_requests(&self) -> Vec<&IORequest>
References to pending requests whose deadline has passed.
Sourcepub fn drain_expired(&mut self) -> Vec<IORequest>
pub fn drain_expired(&mut self) -> Vec<IORequest>
Remove and return all pending requests whose deadline has passed.
Sourcepub fn stats(&self) -> IOSchedulerStats
pub fn stats(&self) -> IOSchedulerStats
Snapshot of current scheduler statistics.
Sourcepub fn config(&self) -> &SchedulerConfig
pub fn config(&self) -> &SchedulerConfig
Borrow the scheduler configuration.
Auto Trait Implementations§
impl Freeze for StorageIOScheduler
impl RefUnwindSafe for StorageIOScheduler
impl Send for StorageIOScheduler
impl Sync for StorageIOScheduler
impl Unpin for StorageIOScheduler
impl UnsafeUnpin for StorageIOScheduler
impl UnwindSafe for StorageIOScheduler
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more