fn Channel(comptime T: type) type
Many producer, many consumer, thread-safe, runtime configurable buffer size. When buffer is empty, consumers suspend and are resumed by producers. When buffer is full, producers suspend and are resumed by consumers.
Fields
getters: field_call,
or_null_queue: field_call,
putters: field_call,
get_count: usize,
put_count: usize,
dispatch_lock: bool,
need_dispatch: bool,
buffer_nodes: []T,
buffer_index: usize,
buffer_len: usize,
Functions
fn deinit(self: *SelfChannel) void
Must be called when all calls to put and get have suspended and no more calls oc…
Must be called when all calls to put and get have suspended and no more calls occur. This can be omitted if caller can guarantee that the suspended putters and getters do not need to be run to completion. Note that this may leave awaiters hanging.
fn get(self: *SelfChannel) callconv(.Async) T
await this function to get an item from the channel. If the buffer is empty, the…
await this function to get an item from the channel. If the buffer is empty, the frame will complete when the next item is put in the channel.
fn getOrNull(self: *SelfChannel) ?T
Get an item from the channel. If the buffer is empty and there are no puts wait…
Get an item from the channel. If the buffer is empty and there are no puts waiting, this returns
null
.fn put(self: *SelfChannel, data: T) void
puts a data item in the channel. The function returns when the value has been ad…
puts a data item in the channel. The function returns when the value has been added to the buffer, or in the case of a zero size buffer, when the item has been retrieved by a getter. Or when the channel is destroyed.