1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use std::cmp::Ordering;
use std::sync::Arc;
use std::time::Instant;

use super::{Node, ScheduledTimer};

/// Entries in the timer heap, sorted by the instant they're firing at and then
/// also containing some payload data.
pub(crate) struct HeapTimer {
    pub(crate) at: Instant,
    pub(crate) gen: usize,
    pub(crate) node: Arc<Node<ScheduledTimer>>,
}

impl PartialEq for HeapTimer {
    fn eq(&self, other: &HeapTimer) -> bool {
        self.at == other.at
    }
}

impl Eq for HeapTimer {}

impl PartialOrd for HeapTimer {
    fn partial_cmp(&self, other: &HeapTimer) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

impl Ord for HeapTimer {
    fn cmp(&self, other: &HeapTimer) -> Ordering {
        self.at.cmp(&other.at)
    }
}