Concurrency & Channels (chan)
The chan module provides CSP-style message passing channels and thread spawning for lock-free communication between threads.
Functions
chan.new() -> ZyraChannel
Creates a new multi-producer, single-consumer communication channel.
chan.clone(channel: ZyraChannel) -> ZyraChannel
Clones a channel endpoint so multiple producer threads can send messages.
chan.send(channel: ZyraChannel, msg: String)
Sends a message into the channel.
chan.recv(channel: ZyraChannel) -> String
Blocks until a message is received from the channel.
chan.try_recv(channel: ZyraChannel) -> String
Non-blocking receive attempt. Returns the message if available, or an empty string if queue is empty.
spawn(task: Fn)
Spawns an independent OS thread to execute the provided closure.