| Crates.io | lock-free |
| lib.rs | lock-free |
| version | 0.1.2 |
| created_at | 2025-06-20 09:39:37.5901+00 |
| updated_at | 2025-06-20 09:44:21.264562+00 |
| description | High-performance lock-free data structures for Rust with zero dependencies |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1719371 |
| size | 130,464 |
A high-performance collection of lock-free data structures implemented in pure Rust with zero external dependencies.
use lock_free::{Stack, Queue, HashMap};
// Stack example
let stack = Stack::new();
stack.push(42);
assert_eq!(stack.pop(), Some(42));
// Queue example
let queue = Queue::new(1024); // Capacity must be power of 2
queue.enqueue("hello");
assert_eq!(queue.dequeue(), Some("hello"));
// HashMap example
let map = HashMap::new();
map.insert("key", "value");
assert_eq!(map.get(&"key"), Some("value"));
All benchmarks on 8-core CPU:
| Structure | Single Thread | Multi Thread (8) | Notes |
|---|---|---|---|
| Stack | 50M ops/sec | 20M ops/sec | Use producer/consumer pattern |
| Queue | 70M ops/sec | 25M ops/sec | World-class performance |
| HashMap | 15M ops/sec | 250M ops/sec (reads) | Excellent read scaling |
| SkipList | 5-10M ops/sec | Good scaling | O(log n) operations |
This library uses unsafe Rust for performance. While thoroughly tested, please note:
cargo build --release
cargo test
cargo bench
See the examples/ directory for more usage patterns:
bench_all.rs - Comprehensive benchmarkstest_simple.rs - Basic functionality testsbench_safe.rs - Safe usage patternsMIT OR Apache-2.0 (dual licensed)
Contributions welcome! Please ensure:
Inspired by: