futures_timer/native/
heap_timer.rs

1use std::cmp::Ordering;
2use std::sync::Arc;
3use std::time::Instant;
4
5use super::{Node, ScheduledTimer};
6
7/// Entries in the timer heap, sorted by the instant they're firing at and then
8/// also containing some payload data.
9pub(crate) struct HeapTimer {
10    pub(crate) at: Instant,
11    pub(crate) gen: usize,
12    pub(crate) node: Arc<Node<ScheduledTimer>>,
13}
14
15impl PartialEq for HeapTimer {
16    fn eq(&self, other: &HeapTimer) -> bool {
17        self.at == other.at
18    }
19}
20
21impl Eq for HeapTimer {}
22
23impl PartialOrd for HeapTimer {
24    fn partial_cmp(&self, other: &HeapTimer) -> Option<Ordering> {
25        Some(self.cmp(other))
26    }
27}
28
29impl Ord for HeapTimer {
30    fn cmp(&self, other: &HeapTimer) -> Ordering {
31        self.at.cmp(&other.at)
32    }
33}