channel<T> function
Creates a new mpsc channel, returning the Sender and Reciever. Each item T
sent by the Sender
will only be seen once by the Reciever. If the Sender calls close
while the Recievers buffer
is not empty, the Reciever will yield the remaining items in the buffer until empty.
Implementation
(Sender<T>, Reciever<T>) channel<T>() {
// broadcast so no buffer
StreamController<T> controller = StreamController<T>.broadcast();
return (controller.sink, Reciever(controller.stream));
}