Capture event stat, change stat source for contexts

This commit is contained in:
Wildan M
2026-05-12 12:24:49 +07:00
parent 97bd0fb4a6
commit bd44956e96
4 changed files with 35 additions and 29 deletions
+14
View File
@@ -82,6 +82,7 @@ static IDLE_CONTEXTS: Mutex<L2, VecDeque<WeakContextRef>> = Mutex::new(VecDeque:
pub struct RunContextData {
set: [VecDeque<WeakContextRef>; 40],
count: usize,
}
impl RunContextData {
@@ -89,8 +90,13 @@ impl RunContextData {
const EMPTY_VEC: VecDeque<WeakContextRef> = VecDeque::new();
Self {
set: [EMPTY_VEC; 40],
count: 0,
}
}
pub fn update_count(&mut self) -> usize {
self.count = self.set.iter().map(|q| q.len()).sum();
self.count
}
}
/// Get the global schemes list, const
@@ -322,3 +328,11 @@ impl Drop for PreemptGuardL2<'_> {
self.context.write(self.token.token()).preempt_locks -= 1;
}
}
pub fn get_contexts_stats(token: &mut CleanLockToken) -> (usize, usize, usize) {
let alive = contexts(token.downgrade()).len();
let running = run_contexts(token.token()).count;
let blocked = idle_contexts(token.downgrade()).len();
(alive, running, blocked)
}