1 package kotlinx.coroutines.channels 2 3 /** 4 * A strategy for buffer overflow handling in [channels][Channel] and [flows][kotlinx.coroutines.flow.Flow] that 5 * controls what is going to be sacrificed on buffer overflow: 6 * 7 * - [SUSPEND] — the upstream that is [sending][SendChannel.send] or 8 * is [emitting][kotlinx.coroutines.flow.FlowCollector.emit] a value is **suspended** while the buffer is full. 9 * - [DROP_OLDEST] — drop **the oldest** value in the buffer on overflow, add the new value to the buffer, do not suspend. 10 * - [DROP_LATEST] — drop **the latest** value that is being added to the buffer right now on buffer overflow 11 * (so that buffer contents stay the same), do not suspend. 12 */ 13 public enum class BufferOverflow { 14 /** 15 * Suspend on buffer overflow. 16 */ 17 SUSPEND, 18 19 /** 20 * Drop **the oldest** value in the buffer on overflow, add the new value to the buffer, do not suspend. 21 */ 22 DROP_OLDEST, 23 24 /** 25 * Drop **the latest** value that is being added to the buffer right now on buffer overflow 26 * (so that buffer contents stay the same), do not suspend. 27 */ 28 DROP_LATEST 29 } 30