fibers_timeout_queue

Crates.iofibers_timeout_queue
lib.rsfibers_timeout_queue
version0.1.0
sourcesrc
created_at2018-09-13 16:51:29.799799
updated_at2018-09-13 16:51:29.799799
descriptionTimeout queue based on `fibers` crate
homepagehttps://github.com/sile/fibers_timeout_queue
repositoryhttps://github.com/sile/fibers_timeout_queue
max_upload_size
id84559
size12,114
Takeru Ohta (sile)

documentation

README

fibers_timeout_queue

Crates.io: fibers_timeout_queue Documentation Build Status Code Coverage License: MIT

This crate provides a timeout queue based on fibers crate.

Documentation

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);
Commit count: 2

cargo fmt