Skip to main content

tokio_timer/wheel/
stack.rs

1use std::borrow::Borrow;
2
3/// Abstracts the stack operations needed to track timeouts.
4pub(crate) trait Stack: Default {
5    /// Type of the item stored in the stack
6    type Owned: Borrow<Self::Borrowed>;
7
8    /// Borrowed item
9    type Borrowed;
10
11    /// Item storage, this allows a slab to be used instead of just the heap
12    type Store;
13
14    /// Returns `true` if the stack is empty
15    fn is_empty(&self) -> bool;
16
17    /// Push an item onto the stack
18    fn push(&mut self, item: Self::Owned, store: &mut Self::Store);
19
20    /// Pop an item from the stack
21    fn pop(&mut self, store: &mut Self::Store) -> Option<Self::Owned>;
22
23    fn remove(&mut self, item: &Self::Borrowed, store: &mut Self::Store);
24
25    fn when(item: &Self::Borrowed, store: &Self::Store) -> u64;
26}