Expand description
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 kovan_channel::{unbounded, select};
use std::thread;
let (s1, r1) = unbounded::<i32>();
let (s2, r2) = unbounded::<i32>();
thread::spawn(move || {
s1.send(10);
});
thread::spawn(move || {
s2.send(20);
});
select! {
v1 = r1 => println!("Received from s1: {}", v1),
v2 = r2 => println!("Received from s2: {}", v2),
}§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.
Re-exports§
pub use flavors::bounded;pub use flavors::unbounded;pub use flavors::after::after;pub use flavors::never::never;pub use flavors::tick::tick;
Modules§
- flavors
- Channel flavors (unbounded, bounded, special).
- select
- Select macro implementation.
- signal
- Signal mechanism for thread synchronization.
Macros§
- select
- Waits on multiple concurrent branches.