embedded_threads/
threadlist.rs1use crate::arch::interrupt::CriticalSection;
2
3use crate::{ThreadId, Threads};
4
5pub(crate) struct ThreadList {
6 pub head: Option<ThreadId>,
7}
8
9impl ThreadList {
10 pub(crate) const fn new() -> Self {
11 Self { head: None }
12 }
13
14 pub(crate) fn pop(&mut self, cs: &CriticalSection) -> Option<ThreadId> {
15 if let Some(head) = self.head {
16 let result = self.head;
17 let thread = unsafe { &Threads::get_mut(cs).threads[head as usize] };
18 self.head = thread.next;
19 result
20 } else {
21 None
22 }
23 }
24}