pub struct TimeSlice { /* private fields */ }
Expand description
Time slice tracking for thread scheduling.
This tracks how much time a thread has used in its current time slice and determines when preemption should occur.
Implementations§
Source§impl TimeSlice
impl TimeSlice
Sourcepub fn new(priority: u8) -> Self
pub fn new(priority: u8) -> Self
Create a new time slice tracker.
§Arguments
priority
- Thread priority (0-255, higher = more important)
Sourcepub fn start_slice(&self, current_time: Instant)
pub fn start_slice(&self, current_time: Instant)
Sourcepub fn update_vruntime(&self, current_time: Instant) -> bool
pub fn update_vruntime(&self, current_time: Instant) -> bool
Sourcepub fn set_priority(&self, new_priority: u8)
pub fn set_priority(&self, new_priority: u8)
Sourcepub fn set_custom_duration(&self, duration: Duration)
pub fn set_custom_duration(&self, duration: Duration)
Sourcepub fn reset_vruntime(&self, new_vruntime: u64)
pub fn reset_vruntime(&self, new_vruntime: u64)
Reset virtual runtime (used for priority inheritance).
Sourcepub fn should_preempt(&self) -> bool
pub fn should_preempt(&self) -> bool
Check if this time slice should be preempted.
This is a convenience method that updates virtual runtime and returns whether preemption should occur.
Auto Trait Implementations§
impl !Freeze for TimeSlice
impl RefUnwindSafe for TimeSlice
impl Send for TimeSlice
impl Sync for TimeSlice
impl Unpin for TimeSlice
impl UnwindSafe for TimeSlice
Blanket Implementations§
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
Mutably borrows from an owned value. Read more