Expand description
§Wait-free synchronization primitives
Wait-freedom is the strongest non-blocking guarantee, ensuring that every thread completes its operations within a bounded number of steps. This library provides a collection of wait-free algorithms.
§Usage
Add the following to your Cargo.toml:
[dependencies]
waitfree-sync = " ... "§Triple Buffer
A wait-free triple buffer for single-producer, single-consumer scenarios.
use waitfree_sync::triple_buffer;
let (mut wr, mut rd) = triple_buffer::triple_buffer();
wr.write(42);
assert_eq!(wr.try_read(), Some(42));
assert_eq!(rd.try_read(), Some(42));§SPSC Queue
A wait-free single-producer, single-consumer queue.
use waitfree_sync::spsc;
let (mut tx, mut rx) = spsc::spsc(8);
tx.try_send("hello").unwrap();
assert_eq!(rx.try_recv(), Some("hello"));§Features
- No locks: All operations are wait-free.
- No dynamic allocation: All memory is allocated up front.
- Suitable for real-time systems: Progress is guaranteed for every thread.
§License
Licensed under either of Apache License, Version 2.0 or MIT license
§Roadmap
- Add nostd support
- Add MPSC/SPMC/MPMC queues
Modules§
- spsc
- Wait-free single-producer single-consumer (SPSC) queue to send data to another thread. Based on the improved FastForward queue.
- triple_
buffer - Wait-free single-producer single-consumer (SPSC) triple buffer to share data between two threads.