Multi-producer multi-consumer channels using Kovan for memory reclamation.
This crate provides high-performance, lock-free channel implementations built on top of the
Kovan memory reclamation system. It offers both
unbounded and bounded channels, along with a powerful select! macro for concurrent operations.
Key Features
- Multi-producer Multi-consumer (MPMC): All channels support multiple concurrent senders and receivers.
- Lock-Free Operations: Core operations are lock-free, ensuring system-wide progress.
- Blocking Support: Channels support blocking
send(when full) andrecv(when empty) operations. - Select Macro: A
select!macro for waiting on multiple channel operations, including adefaultcase. - Special Channels: Includes
after,tick, andneverchannels for timing and control flow. - Kovan Integration: Uses Kovan's safe memory reclamation to manage channel nodes without garbage collection.
Channel Flavors
- [
unbounded()]: A channel with infinite capacity. It never blocks on send, but can block on receive. - [
bounded()]: A channel with fixed capacity. It blocks on send when full and on receive when empty.
Example
use ;
use thread;
let = ;
let = ;
spawn;
spawn;
select!
Safety
This crate uses unsafe code internally for performance and to interface with the Kovan memory
reclamation system. However, it exposes a safe API. Memory safety is guaranteed by Kovan's
epoch-based reclamation, ensuring that nodes are only freed when no threads are accessing them.