Timed Queue

A queue that drops its content after a given amount of time.

Example

To implement an FPS counter, you could use the following technique:

``` use std::thread; use std::time::Duration; use ttl_queue::TtlQueue;

let mut fpscounter = TtlQueue::new(Duration::fromsecs_f64(1.0));

for i in 0..100 { // Register a new frame and return the number of frames observed // within the last second. let fps = fpscounter.refreshandpushback(()); debug_assert!(fps >= 1);

// Sleep 10 ms to achieve a ~100 Hz frequency.
thread::sleep(Duration::from_millis(10));

}

let fps = fpscounter.refresh(); debugassert!(fps >= 95 && fps <= 105); ```