forked from async-rs/futures-timer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheap_timer.rs
More file actions
33 lines (27 loc) · 749 Bytes
/
Copy pathheap_timer.rs
File metadata and controls
33 lines (27 loc) · 749 Bytes
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 crate::Instant;
use std::cmp::Ordering;
use std::sync::Arc;
use crate::{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)
}
}