Expand description
Channel operations for CSP-style concurrency.
Channels are the primary communication mechanism between strands. They use May’s MPMC channels with cooperative blocking.
§Zero-Mutex Design
Channels are passed directly as Value::Channel on the stack. There is NO
global registry and NO mutex contention. Send/receive operations work
directly on the channel handles. The closed flag is a single atomic
load on the send hot path; no locking.
§Non-Blocking Guarantee
All channel operations (send, receive) cooperatively block using May’s
scheduler. They NEVER block OS threads — May handles scheduling other
strands while waiting.
§Multi-Consumer Support
Channels support multiple producers AND multiple consumers (MPMC). Each message is delivered to exactly one receiver (work-stealing semantics).
§chan.close Semantics
Issue #499: chan.close is real, not “equivalent to drop”. The
implementation uses the same typed-sentinel pattern as WeaveChannelData
— see crates/core/src/value.rs::ChannelMsg and
docs/design/CHAN_CLOSE_SEMANTICS.md.
chan.closeatomically sets a sharedclosedflag (CAS) and, on the first close, enqueues a singleChannelMsg::Closedsentinel.chan.sendshort-circuits tofalsewhen the flag is set.chan.receivereturns( value true )onChannelMsg::Value. OnChannelMsg::Closedit re-broadcasts the sentinel (so the next blocked receiver also wakes — Go-style propagation across an unknown number of MPMC consumers) and returns( default false ).
The user-facing API is unchanged: programs still write Channel, still
call chan.make/chan.send/chan.receive/chan.close, still see the
( value Bool ) success-flag shape.
§Stack Effects
chan.make: ( – Channel )chan.send: ( value Channel – Bool ) consumes the channelchan.receive: ( Channel – value Bool ) consumes the channelchan.close: ( Channel – ) consumes the channel
Re-exports§
pub use patch_seq_chan_receive as receive;pub use patch_seq_chan_send as send;pub use patch_seq_close_channel as close_channel;pub use patch_seq_make_channel as make_channel;
Statics§
Functions§
- patch_
seq_ ⚠chan_ receive - Receive a value from a channel.
- patch_
seq_ ⚠chan_ send - Send a value through a channel.
- patch_
seq_ ⚠close_ channel - Close a channel.
- patch_
seq_ ⚠make_ channel - Create a new channel.