1 unstable release
Uses old Rust 2015
0.1.0 | Sep 13, 2018 |
---|
#16 in #fibers
Used in 2 crates
11KB
133 lines
fibers_timeout_queue
This crate provides a timeout queue based on fibers
crate.
Examples
use fibers_timeout_queue::TimeoutQueue;
use std::time::Duration;
use std::thread;
let mut queue = TimeoutQueue::new();
assert_eq!(queue.pop(), None); // `queue` is empty
queue.push(1, Duration::from_millis(1000));
queue.push(2, Duration::from_millis(100));
queue.push(3, Duration::from_millis(10));
assert_eq!(queue.pop(), None); // No expired items
thread::sleep(Duration::from_millis(50));
assert_eq!(queue.pop(), Some(3)); // There is an expired item
assert_eq!(queue.pop(), None);
Dependencies
~1–1.2MB
~20K SLoC