Io module

make_channel

procedureextensionexperimentalSource

A channel that holds up to capacity values, made with context.allocator.

Example↗
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);
});
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 send blocks. 0 makes a send wait for a receive.

Returns

Example↗
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);
});

See also