Search⌘ K
AI Features

Channel Parameters

Explore how Kotlin coroutine channels manage buffer overflow using options like SUSPEND, DROP_OLDEST, and DROP_LATEST. Understand handling undelivered elements, and learn about fan-out and fan-in patterns for distributing and merging data across multiple coroutines. Gain practical knowledge of channel behavior and pipeline creation.

On buffer overflow

To customize channels further, we can control what happens when the buffer is full (onBufferOverflow parameter). These are the options:

  • SUSPEND (default): When the buffer is full, suspend on the send method.

  • DROP_OLDEST: When the buffer is full, drop the oldest element.

  • DROP_LATEST: When the buffer is full, drop the latest element.

As we might guess, the channel capacity of Channel.CONFLATED ...