UNLIMITED

const val UNLIMITED: Int(source)

An unlimited buffer capacity.

Channel(UNLIMITED) creates a channel with an unlimited buffer, which never suspends the sender. The total amount of elements that can be sent to the channel is limited only by the available memory.

If BufferOverflow is specified for the channel, it is completely ignored, as the channel never suspends the sender.

val channel = Channel<Int>(Channel.UNLIMITED)
repeat(1000) {
channel.trySend(it)
}
repeat(1000) {
check(channel.tryReceive().getOrNull() == it)
}