pub struct RunningRef(pub Thread);
Expand description
A reference to a thread that is currently running on a CPU.
This type represents a thread that is actively executing on a CPU.
Tuple Fields§
§0: Thread
Implementations§
Source§impl RunningRef
impl RunningRef
Sourcepub fn stop_running(self) -> ReadyRef
pub fn stop_running(self) -> ReadyRef
Convert this running reference back to a ready reference.
This should be called when the thread is preempted or yields.
Sourcepub fn should_preempt(&self) -> bool
pub fn should_preempt(&self) -> bool
Check if this thread should be preempted.
This updates the thread’s virtual runtime and returns true if the time slice has expired.
Sourcepub fn block(self)
pub fn block(self)
Mark this thread as blocked.
This should be called when the thread blocks on I/O or synchronization.
Sourcepub fn finish(self)
pub fn finish(self)
Mark this thread as finished.
This should be called when the thread’s entry point returns.
Sourcepub fn prepare_preemption(&self) -> ReadyRef
pub fn prepare_preemption(&self) -> ReadyRef
Prepare this thread for preemption.
This saves the current state and returns a ReadyRef that can be re-enqueued.
Sourcepub fn last_cpu(&self) -> usize
pub fn last_cpu(&self) -> usize
Get the CPU this thread last ran on.
For now, return 0 as a placeholder. In a real implementation, this would track the actual CPU assignment.
Sourcepub fn time_slice(&self) -> &TimeSlice
pub fn time_slice(&self) -> &TimeSlice
Get access to the thread’s time slice for scheduler decisions.
Trait Implementations§
Source§impl Clone for RunningRef
impl Clone for RunningRef
Source§fn clone(&self) -> RunningRef
fn clone(&self) -> RunningRef
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more