use super::CpuLocal;
use crate::{sched::CpuId, thread::ThreadId};
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct CpuSnapshot {
owner: CpuId,
current: Option<ThreadId>,
runnable: usize,
need_resched: bool,
}
impl CpuSnapshot {
pub(crate) fn capture(cpu: &CpuLocal) -> Self {
Self {
owner: cpu.owner(),
current: cpu.current(),
runnable: cpu.runnable_count(),
need_resched: cpu.needs_reschedule(),
}
}
pub const fn owner(self) -> CpuId {
self.owner
}
pub const fn current(self) -> Option<ThreadId> {
self.current
}
pub const fn runnable(self) -> usize {
self.runnable
}
pub const fn need_resched(self) -> bool {
self.need_resched
}
}