SQueue is a sized queue implemented in Rust.
This is just a simple wrapper over a standard Rust VecDeque. It makes a few opinionated choices, so as to choose whether one should pop/push on front/back, and trims the API to the minimum so that it can only serve as a simple FIFO queue.
The main difference between this and using a standard queue, is that this one is capped in size, and will drop the oldest items when pushing more than its allowed capacity.
On top of this, provides a sync thread-safe implementation, which can be shared between threads. But nothing crazy, just a simple wrapper, really.
Project spawned from HashLRU.
SQueue is between the toy project and something you could use. It comes with with a rather complete test harness and tries to have reasonable documentation, so that's a plus. OTOH it is quite young, and to my knowledge not used in production anywhere.
In doubt, use vanilla VecDeque.
```rust use squeue::Queue;
let mut queue: Queue
Taken from a random CI job:
running 6 tests
test tests::bench_read_usize_builtin_vecdeque ... bench: 0 ns/iter (+/- 0)
test tests::bench_read_usize_squeue_queue ... bench: 0 ns/iter (+/- 0)
test tests::bench_read_usize_squeue_sync_queue ... bench: 16 ns/iter (+/- 0)
test tests::bench_write_usize_builtin_vecdeque ... bench: 10 ns/iter (+/- 28)
test tests::bench_write_usize_squeue_queue ... bench: 3 ns/iter (+/- 0)
test tests::bench_write_usize_squeue_sync_queue ... bench: 21 ns/iter (+/- 0)
test result: ok. 0 passed; 0 failed; 0 ignored; 6 measured; 0 filtered out; finished in 11.75s
Not the results of thorough intensive benchmarking but the general idea is:
To run the benchmarks:
shell
cd bench
rustup default nightly
cargo bench
SQueue is licensed under the MIT license.