skip to content
[readonly]
==> README.md <==
1# @ajax/mesh-chan
2
3A channel of fixed-size messages between threads with the semantics meshd's Rust relied on
4(`std::sync::mpsc`): many senders and one receiver, messages in send order, unbounded or bounded
5(`try_send` refuses when full, as `sync_channel`), sends fail once the receiver is gone, receives report
6"disconnected" once every sender is gone and nothing is queued, and receives can wait forever, for a
7timeout on the monotonic clock, or not at all. A reference count keeps the channel alive for its last
8holder; messages left behind go to an optional `drop` function so what they own is freed.
9
10Also `mesh_mono_ms`, `mesh_mono_us` and `mesh_sleep_us` (the monotonic clock the deadlines use).
11
12## Ported from
13
14[alpha-rust-mesh](https://github.com/rsafier/alpha-rust-mesh) (Richard Safier, MIT): meshd's threads talk
15through `std::sync::mpsc` channels (`crates/mesh-host/src/shared.rs`: `Cmd`, `PeerEvent`, `JobEvent`, the
16link queues); this is that, in C over pthreads.
17
18## Tests
19
20- `tests/chan.c`: order and growth, a producer thread (10 000 messages, in order, then disconnected),
21  timeouts, bounded `try_send`, a closed receiver, and messages dropped at release.
22
23## Licence
24
25MIT. See the repository's LICENSE.