ec
12/03/2019, 7:45 PMec
12/03/2019, 8:04 PMsend
on a channel from GlobalScope.launch {}
but it doesnt seem to add too much value over just using BlockingQueue
for this case, I guessZach Klippenstein (he/him) [MOD]
12/03/2019, 8:28 PMChannel(capacity = UNLIMITED)
to get an unbounded channel, and use channel.offer
instead of channel.send
to send to the channel without suspending.ec
12/03/2019, 8:35 PMZach Klippenstein (he/him) [MOD]
12/03/2019, 9:50 PMfrom performance standpoint is Channels better for Kotlin compiler?Better than what, using a
LinkedBlockingQueue
? I don’t think the compiler cares either way. Unlimited-capacity channels are effectively linked blocking queues that suspend instead of block, which lets you scale the number of suspending operations a lot more than blocking ones because they’re not pinned to threads.
As for one vs multi channel performance, I’m not sure. I’d build it the simplest way first, then benchmark + profile, and optimize from there.