Connects to the channel called name as its writer and returns (success, channel). Give the channel back with writer_disconnect.
It fails when the channel does not exist yet, when it is not a valid channel, when its reader has gone, or when
another writer is connected. A missing channel is logged as an error through context.logger unless
name_not_found_is_quiet is true, which is meant for a writer that polls until the reader has started. After a
writer_disconnect a new writer may connect. Uses context.allocator for a small record that writer_disconnect frees.
name := tprint("jai-doc-%", to_nanoseconds(current_time_monotonic()));
missing, nothing := writer_connect(name, name_not_found_is_quiet = true);
assert(!missing); // no reader yet
ok, reader := reader_create_channel(name, 512);
assert(ok);
connected, writer := writer_connect(name);
assert(connected);
second, other := writer_connect(name, name_not_found_is_quiet = true);
assert(!second); // one writer at a time
assert(writer_disconnect(*writer));
connected, writer = writer_connect(name);
assert(connected);
assert(writer_disconnect(*writer));
assert(reader_release_channel(*reader));Doesn't run in the browser (skipped on wasm).
writer_connect :: (
name: string,
name_not_found_is_quiet := false
) -> (success: bool, channel: Write_Channel)
Connects to the channel called name as its writer and returns (success, channel). Give the channel back with writer_disconnect.
It fails when the channel does not exist yet, when it is not a valid channel, when its reader has gone, or when
another writer is connected. A missing channel is logged as an error through context.logger unless
name_not_found_is_quiet is true, which is meant for a writer that polls until the reader has started. After a
writer_disconnect a new writer may connect. Uses context.allocator for a small record that writer_disconnect frees.
Parameters
- name: string
- name_not_found_is_quiet := false
Returns
- success: bool
- channel: Write_Channel
name := tprint("jai-doc-%", to_nanoseconds(current_time_monotonic()));
missing, nothing := writer_connect(name, name_not_found_is_quiet = true);
assert(!missing); // no reader yet
ok, reader := reader_create_channel(name, 512);
assert(ok);
connected, writer := writer_connect(name);
assert(connected);
second, other := writer_connect(name, name_not_found_is_quiet = true);
assert(!second); // one writer at a time
assert(writer_disconnect(*writer));
connected, writer = writer_connect(name);
assert(connected);
assert(writer_disconnect(*writer));
assert(reader_release_channel(*reader));Doesn't run in the browser (skipped on wasm).