https://kotlinlang.org logo
Title
s

SrSouza

05/17/2020, 5:29 PM
HI folks, what is the difference of
Channel.offer
and
Channel.send
, I know that send suspend and offer don't, but what is the usage difference?
s

streetsofboston

05/17/2020, 5:36 PM
With
send
, the receiver(s) will always get the sent value. With
offer
, the receiver(s) may not get offered value, it could be dropped if the buffer is full.
g

gildor

05/18/2020, 8:15 AM
you can use offer from non-suspend function, which is very useful when you write adapters for coroutines from non-coroutine code. Also send is a way to achieve backpressure, slowdown senders if consumer is slower