Struct std::AsyncChannel
generic<T: Send> struct AsyncChannel {
[]T buf;
unsigned long head;
unsigned long count;
int closed;
struct WaitList senders;
struct WaitList receivers;
struct Spinlock lk;
}A bounded multi-producer, multi-consumer FIFO over a caller's buffer.
Fields
index of the oldest value
values in the buffer
waiting for room
waiting for a value
Methods
A channel holding at most storage.len values.
Future: Ready(1) once 'v' is in the channel, Ready(0) if it's closed.
Future: Ready(some(v)) with the oldest value, Ready(null) once the channel is closed and empty.
Without waiting: 1 sent, 0 full, -1 closed.
Without waiting: the oldest value, or null if empty (or closed and empty).
No more sends: pending and future sends get 0, receivers drain what is buffered and then get null.
Closes it, releases the waiting wakers, and drops the values still buffered. Nothing may use the channel (or a future from it) after.