@channels
The @channels module provides message passing between threads. Compiler-only feature; requires POSIX threads.
Import
import @channels
Functions
open()
(capacity int) -> Channel
Creates a buffered channel with the given capacity.
import @channels
do main() {
mut ch = channels.open(10)
ensure channels.close(ch)
// Use the channel...
}
send()
(ch Channel, value)
Sends a value into a channel.
channels.send(ch, "hello")
channels.send(ch, 42)
receive()
(ch Channel) -> T
Receives a value from a channel. Blocks until a value is available.
mut msg = channels.receive(ch)
println(msg)
close()
(ch Channel)
Closes a channel.
channels.close(ch)