tokio/runtime/time_alt/
wake_queue.rs1use super::{Entry, EntryHandle, WakeQueueEntry};
2use crate::util::linked_list;
3
4type EntryList = linked_list::LinkedList<WakeQueueEntry, Entry>;
5
6#[derive(Debug)]
8pub(crate) struct WakeQueue {
9 list: EntryList,
10}
11
12impl Drop for WakeQueue {
13 fn drop(&mut self) {
14 while let Some(hdl) = self.list.pop_front() {
16 drop(hdl);
17 }
18 }
19}
20
21impl WakeQueue {
22 pub(crate) fn new() -> Self {
23 Self {
24 list: EntryList::new(),
25 }
26 }
27
28 pub(crate) fn is_empty(&self) -> bool {
29 self.list.is_empty()
30 }
31
32 pub(crate) unsafe fn push_front(&mut self, hdl: EntryHandle) {
38 self.list.push_front(hdl);
39 }
40
41 pub(crate) fn wake_all(mut self) {
43 while let Some(hdl) = self.list.pop_front() {
44 hdl.wake();
45 }
46 }
47}
48
49#[cfg(test)]
50mod tests;