| 1 |
use std::cmp::Ordering; |
| 2 |
use std::sync::Arc; |
| 3 |
use std::time::Instant; |
| 4 |
|
| 5 |
use 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. |
| 9 |
pub(crate) struct HeapTimer { |
| 10 |
pub(crate) at: Instant, |
| 11 |
pub(crate) gen: usize, |
| 12 |
pub(crate) node: Arc<Node<ScheduledTimer>>, |
| 13 |
} |
| 14 |
|
| 15 |
impl PartialEq for HeapTimer { |
| 16 |
fn eq(&self, other: &HeapTimer) -> bool { |
| 17 |
self.at == other.at |
| 18 |
} |
| 19 |
} |
| 20 |
|
| 21 |
impl Eq for HeapTimer {} |
| 22 |
|
| 23 |
impl PartialOrd for HeapTimer { |
| 24 |
fn partial_cmp(&self, other: &HeapTimer) -> Option<Ordering> { |
| 25 |
Some(self.cmp(other)) |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
impl Ord for HeapTimer { |
| 30 |
fn cmp(&self, other: &HeapTimer) -> Ordering { |
| 31 |
self.at.cmp(&other.at) |
| 32 |
} |
| 33 |
} |