ax_task/sched/system/cpu/
snapshot.rs1use super::CpuLocal;
4use crate::{sched::CpuId, thread::ThreadId};
5
6#[derive(Clone, Copy, Debug, Eq, PartialEq)]
8pub struct CpuSnapshot {
9 owner: CpuId,
10 current: Option<ThreadId>,
11 runnable: usize,
12 need_resched: bool,
13}
14
15impl CpuSnapshot {
16 pub(crate) fn capture(cpu: &CpuLocal) -> Self {
17 Self {
18 owner: cpu.owner(),
19 current: cpu.current(),
20 runnable: cpu.runnable_count(),
21 need_resched: cpu.needs_reschedule(),
22 }
23 }
24
25 pub const fn owner(self) -> CpuId {
27 self.owner
28 }
29
30 pub const fn current(self) -> Option<ThreadId> {
32 self.current
33 }
34
35 pub const fn runnable(self) -> usize {
37 self.runnable
38 }
39
40 pub const fn need_resched(self) -> bool {
42 self.need_resched
43 }
44}