July 2018
Intermediate to advanced
266 pages
7h 11m
English
Currently the only implementation of unbuffered channels is RendezvousChannel. This implementation of a channel has no buffer at all, so calling send() on it will suspend it until a receiver calls receive() on the channel. You can instantiate this type of channel in a few different ways. You can do it by calling its constructor:
val channel = RendezvousChannel<Int>()
You can also use the Channel() function. This function has two implementations, one that takes the buffer capacity as parameter, and another that doesn't take any parameters. To get a RendezvousChannel you can call the function without a parameter:
val rendezvousChannel = Channel<Int>()
You will have the same result if you send a capacity of zero:
val rendezvousChannel ...Read now
Unlock full access