Jacques
High-performance, lock-free Multi-Producer Multi-Consumer (MPMC) queue library designed for concurrent applications requiring maximum throughput and minimal latency. Based on the queue implementation of Erez Strauss.
Features
- Lock-free algorithms: Zero mutex contention with atomic operations
- MPMC support: Multiple producers and consumers can operate concurrently
- Zero-allocation operation: No dynamic allocation during push/pop operations
- Horizontal scaling: Pack-based load distribution across multiple queues
- Type safety: Comprehensive compile-time guarantees with generic design
- Memory efficient: Packed 128-bit atomic operations with sequence numbers
- Rich API: Blocking, non-blocking, conditional, and bulk operations
Performance Characteristics
- Throughput: >100M operations/second on modern hardware
- Latency: Sub-microsecond operation latency
- Scalability: Linear scaling with core count using queue packs
- Memory: Constant memory usage, no dynamic allocation
Queue Types
Owned Queue (MpmcQueue)
The foundational lock-free queue for Copy types:
use ;
let = .capacity.channels?;
producer.push?;
assert_eq!;
Pointer Queue (PointerQueue)
Store non-Copy types by wrapping them in Arc<T>:
use pointer_queue;
use Arc;
use ;
let = .capacity.channels?;
let msg = new;
producer.push?;
assert_eq!;
Queue Pack (QueuePack)
Horizontal scaling with multiple independent queues:
use queue_pack;
use ;
// 4 queues, scan every 16 operations
let = .queue_capacity.channels?;
producer.push?;
assert_eq!;
Advanced Features
- Sequence Numbers: Track operation ordering across concurrent access
- Conditional Operations: Process elements based on predicates
- Bulk Processing: Consume multiple elements efficiently
- Thread Safety: All queue types are
Send + Sync
Installation
Add this to your Cargo.toml:
[]
= "0.1"
Documentation
For full documentation, visit docs.rs/jacques.
Minimum Supported Rust Version (MSRV)
Jacques requires Rust 1.88 or later.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.