Deadqueue is a dead simple async queue with back pressure support.
This crate provides three implementations:
Unlimited (deadqueue::unlimited::Queue
)
crossbeam_queue::SegQueue
unlimited
feature in your Cargo.toml
Resizable (deadqueue::resizable::Queue
)
deadqueue::unlimited::Queue
resizable
feature in your Cargo.toml
Limited (deadqueue::limited::Queue
)
crossbeam_queue::ArrayQueue
limited
feature in your Cargo.toml
| Feature | Description | Extra dependencies | Default |
| ------- | ----------- | ------------------ | ------- |
| unlimited
| Enable unlimited queue implementation | – | yes |
| resizable
| Enable resizable queue implementation | deadqueue/unlimited
| yes |
| limited
| Enable limited queue implementation | – | yes |
```rust,ignore use std::sync::Arc;
const TASKCOUNT: usize = 1000; const WORKERCOUNT: usize = 10;
type TaskQueue = deadqueue::limited::Queue
async fn main() { let queue = Arc::new(TaskQueue::new(10)); for i in 0..TASKCOUNT { queue.push(i); } let mut futures = Vec::new(); for _ in 0..WORKERCOUNT { let queue = queue.clone(); futures.push(tokio::spawn(async move { let task = queue.pop().await; assert!(task > 1); })); } for future in futures { future.await; } assert_eq!(queue.len(), 0); } ```
Licensed under either of
at your option.