https://kotlinlang.org logo
Title
c

coder82

09/05/2019, 10:00 AM
It would be nice if IDE would know it's a conflated channel and not put the suspend arrow indicator when calling send() on it... maybe it was better a specific type than an initialization parameter
g

gildor

09/05/2019, 10:03 AM
It’s not nice, because send() is still suspend function, even if it invoking very fast
c

coder82

09/05/2019, 10:03 AM
is it? but the documentation says it won't suspend and offer returns always true
g

gildor

09/05/2019, 10:04 AM
if you know that it’s conflated channel, just
offer()
, if for some reason you want to avoid suspend indicator
☝️ 1
c

coder82

09/05/2019, 10:04 AM
true
g

gildor

09/05/2019, 10:04 AM
it won’t suspend
it’s just return immediately, but it still suspend function and cannot be called out of suspending lambda
c

coder82

09/05/2019, 10:05 AM
ok
m

Matej Drobnič

09/10/2019, 5:36 AM
Let me steal this thread with similar question: Does that mean that
offer
and
send
are competely identical with conflated channel or is
send
still slightly more expensive since it needs to drag whole coroutine machinery with it?
g

gildor

09/10/2019, 6:00 AM
Yes, offer is a bit more efficient because doesn’t create suspend point as send
m

Matej Drobnič

09/10/2019, 6:14 AM
so basically we should alwys use offer on conflated channels?
Or is there a reason to use send?
g

gildor

09/10/2019, 6:17 AM
I wouldn’t say that “we should”
reason to use send
If you want cancellation/suspend point
or just to make it more future proof, because essentially you must be 100% sure that it’s conflated channel
👍 1