On channel open and not full

If the channel is open and it's not full, offer() will add the element to the queue. This is the only way to add elements to a channel without it happening from a suspending computation:

val channel = Channel<Int>(1)
channel.offer(2) // true
channel.receive() // 2
The send() implementation in AbstractSendChannel tries to add the element to the queue using offer() first; that way, the sender will not suspend if it's not needed.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.99.71