Kotlin 频道 - 是否有非暂停接收?

Kotlin channel - is there a non-suspending receive?

显然,如果我们针对空通道调用 channel.receive(),它会暂停,这与此处 in official docs 的记录完全相同。有没有办法立即 return 变成 null,就像 ConcurrentLinkedQueuepoll() 那样?

是的,我们可以使用 tryReceive():

channel.tryReceive().getOrNull()