A channel that holds up to capacity values, made with context.allocator.
Io :: #import "Extensions/Io";
Io.io_run(() {
channel := Io.make_channel(int, 2);
defer Io.free_channel(channel);
Io.send(channel, 1);
value, error := Io.recv(channel);
assert(error == .NONE && value == 1);
});- capacity: how many values it holds before
sendblocks. 0 makes a send wait for a receive.
make_channel :: ($T: Type, capacity := 0) -> *Channel(T)
A channel that holds up to capacity values, made with context.allocator.
Parameters
- $T: Type
- capacity := 0
- how many values it holds before
sendblocks. 0 makes a send wait for a receive.
Returns
- *Channel(T)
Io :: #import "Extensions/Io";
Io.io_run(() {
channel := Io.make_channel(int, 2);
defer Io.free_channel(channel);
Io.send(channel, 1);
value, error := Io.recv(channel);
assert(error == .NONE && value == 1);
});