1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! Fast typed in-process MPSC and MPMC channels built from SPSC rings.
//!
//! Every sender owns one bounded ring. Producers therefore avoid contention on
//! a shared queue tail, while receiver-side batching amortizes synchronization.
//! Sender registration is dynamic and dropped lane slots are reused.
//!
//! # Choose a channel
//!
//! - [`mpsc`] has one receiver, preserves FIFO within each sender lane, and has
//! the smallest receive-side overhead.
//! - [`mpmc`] has cloneable competing receivers and relaxed ordering. Receivers
//! stage batches in bounded queues that other receivers can steal.
//!
//! Both variants provide nonblocking, blocking, timeout, and deadline APIs.
//! Capacity is a high-water mark per sender, not one shared channel bound.
//!
//! # Teardown
//!
//! Constructors default to [`teardown::Deferred`]: unread ring payloads may
//! remain alive until their sender drops. Choose [`teardown::Coordinated`] with
//! [`mpsc::channel_with_policy`] or [`mpmc::channel_with_policy`] to reclaim
//! payloads independently of idle sender lifetimes. An overlapping send can
//! finish cleanup after receiver drop returns, without blocking that drop on a
//! paused producer. The choice is per channel and inherited by cloned handles.
//!
//! # Example
//!
//! ```
//! use fanring::mpsc;
//!
//! let (mut tx0, mut rx) = mpsc::channel(64);
//! let mut tx1 = tx0.try_clone().expect("receiver is alive");
//!
//! tx0.send("first").unwrap();
//! tx1.send("second").unwrap();
//!
//! let mut values = [rx.recv().unwrap(), rx.recv().unwrap()];
//! values.sort_unstable();
//! assert_eq!(values, ["first", "second"]);
//! ```
//!
//! See each channel module for its exact ordering, capacity, and disconnection
//! contracts.