Module channel

Module channel 

Source
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 with zero locking overhead.

§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). Multiple strands can receive from the same channel concurrently - each message is delivered to exactly one receiver (work-stealing semantics).

§Stack Effects

  • chan.make: ( – Channel ) - creates a new channel
  • chan.send: ( value Channel – Bool ) - sends value, returns success
  • chan.receive: ( Channel – value Bool ) - receives value and success flag

§Error Handling

All operations return success flags - errors are values, not crashes:

  • chan.send: ( value Channel – Bool ) - returns true on success, false on closed
  • chan.receive: ( Channel – value Bool ) - returns value and success flag

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;

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 (drop it from the stack)
patch_seq_make_channel
Create a new channel