| Crates.io | drop-queue |
| lib.rs | drop-queue |
| version | 0.0.4 |
| created_at | 2025-07-22 20:17:16.318685+00 |
| updated_at | 2025-07-22 20:23:43.228019+00 |
| description | drop-queue, is a simple drop queue system for async operations. (Until async-drop is a thing) |
| homepage | |
| repository | https://github.com/kjuulh/drop-queue |
| max_upload_size | |
| id | 1763953 |
| size | 27,676 |
drop-queue is a simple, composable async drop queue for Rust โ built to run queued tasks in FIFO order and ensure graceful shutdown via draining. It's useful in lifecycle-managed environments (e.g., notmad) or as a lightweight alternative until async drop is stabilized in Rust.
๐ก Tasks are executed one at a time. If the queue is marked for draining, no further items can be added.
notmad for graceful component lifecycle controlSend + Sync + 'static guaranteedCargo.toml[dependencies]
drop-queue = "*"
notmad integration (optional)[dependencies]
drop-queue = { version = "*", features = ["notmad"] }
use drop-queue::DropQueue;
use tokio::sync::oneshot;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let queue = DropQueue::new();
let (tx, rx) = oneshot::channel();
queue.assign(|| async move {
println!("Running closure task");
tx.send(()).unwrap();
Ok(())
})?;
queue.process_next().await?;
rx.await?;
Ok(())
}
notmadIf using the notmad lifecycle framework:
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let queue = drop-queue::DropQueue::new();
let app = notmad::Mad::new().add(queue);
app.run().await?;
Ok(())
}
This will process tasks until the cancellation token is triggered, e.g., via SIGINT.
You can signal the queue to stop accepting new items and finish processing the current ones:
queue.drain().await?;
After this call, any further assign() will panic.
Run the test suite using:
cargo test
MIT