skip to content
[readonly]

A thread-safe channel of fixed-size messages with timeouts, as Rust's std::sync::mpsc

sh
$ sexc add @ajax/mesh-chan
  • total 3
  • drwxr-xr-x-../
  • drwxr-xr-x-Oct 27 05:23v/# 1 version
  • drwxr-xr-x-Oct 27 05:23files/# the files of 0.1.0
latest
0.1.0, published Oct 27 05:23 by ajax
owners
ajax
license
MIT
dependencies
@ajax/mesh-buf ^0.1.0, @ajax/mesh-check ^0.1.0
dependents
@ajax/mesh-control, @ajax/mesh-driver, @ajax/mesh-fleetd, @ajax/mesh-host-block, @ajax/mesh-http-relay, @ajax/mesh-infer-wire, @ajax/mesh-inferd, @ajax/mesh-jobd, @ajax/mesh-publish, @ajax/mesh-reply, @ajax/mesh-samplers, @ajax/mesh-shared, @ajax/meshd
keywords
mesh alphaos channel mpsc threads
homepage
https://github.com/thomasdavis/alpha-c-mesh/tree/main/packages/mesh-chan
repository
https://github.com/thomasdavis/alpha-c-mesh
==> 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.