Types
struct Channel#
Functions
Creates a new value with the supplied configuration.
capacity: Buffered slots; zero makes every send wait for a receiver.
async fn main() {
let messages = std.channel.new<string>(1)
await messages.send("moon")
println(messages.len())
match await messages.recv() {
some(message) => println(message),
none => println("closed"),
}
messages.close()
println(messages.is_closed())
}Sends a value through the channel.
channel: Channel to send on.value: Value to hand to the next receiver.
Receives the next channel value, or none after closure.
channel: Channel to receive from.
Closes the resource.
channel: Channel to close; pending receivers then seenone.
Returns the number of elements.
channel: Channel whose buffered count is returned.
Reports whether the channel has been closed.
channel: Channel to test.