For the More Curious: Other Channel Behaviors

Channels come in multiple flavors, and the type of channel determines how the send and receive functions behave.

Rendezvous channels

When you call the Channel constructor with no arguments, you get the default rendezvous channel. This is the kind of channel you used in this chapter.

A rendezvous channel is a channel that has no buffer. When you send an item into a rendezvous channel, the send function suspends until a receiver calls receive from the channel to obtain the value. Similarly, if you call receive before send, your code will suspend until a value is sent to the channel.

(Why “rendezvous”? The send and receive calls wait for each other to meet up – a rendezvous, ...

Get Kotlin Programming: The Big Nerd Ranch Guide, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.