23 releases (10 breaking)

0.12.0 Jun 10, 2023
0.10.0 Apr 7, 2023
0.9.0 Mar 31, 2023
0.0.1-beta.16 Dec 18, 2022
0.0.1-beta.12 Nov 8, 2022

#508 in Rust patterns

Download history 6/week @ 2023-08-03 36/week @ 2023-08-10 49/week @ 2023-08-17 24/week @ 2023-08-24 5/week @ 2023-08-31 48/week @ 2023-09-07 41/week @ 2023-09-14 5/week @ 2023-09-21 17/week @ 2023-09-28 9/week @ 2023-10-05 6/week @ 2023-10-12 13/week @ 2023-10-19 43/week @ 2023-10-26 10/week @ 2023-11-02 47/week @ 2023-11-09 10/week @ 2023-11-16

112 downloads per month
Used in 2 crates (via redis-swapplex)

MIT license

1.5K SLoC

Stack Queue

License Cargo Documentation

A heapless auto-batching queue featuring deferrable batching by way of negotiating exclusive access over task ranges on thread-owned circular buffers. As tasks continue to be enqueued until batches are bounded, doing so can be deferred until after a database connection has been acquired as to allow for opportunitistic batching. This delivers optimal batching at all workload levels without batch collection overhead, superfluous timeouts, nor unnecessary allocations.


Impl one of the following while using the local_queue macro:

Optimal Runtime Configuration

For best performance, exclusively use the Tokio runtime as configured via the tokio::main or tokio::test macro with the crate attribute set to async_local while the barrier-protected-runtime feature is enabled on async-local. Doing so configures the Tokio runtime with a barrier that rendezvous runtime worker threads during shutdown in a way that ensures tasks never outlive thread local data owned by runtime worker threads and obviates the need for Box::leak as a means of lifetime extension.

Benchmark results // batching 16 tasks

crossbeam flume TaskQueue BackgroundQueue tokio::mpsc
1.67 us (✅ 1.00x) 1.95 us (❌ 1.17x slower) 942.72 ns (✅ 1.77x faster) 638.45 ns (🚀 2.62x faster) 1.91 us (❌ 1.14x slower)

Stable Usage

This crate conditionally makes use type_alias_impl_trait and impl_trait_in_assoc_type to allow async fns in traits to be unboxed. To compile on stable the boxed feature flag can be used to downgrade async_t::async_trait to async_trait::async_trait.


~520K SLoC