https://kotlinlang.org logo
#coroutines
Title
# coroutines
v

vaskir

06/16/2017, 8:15 AM
I'm not saying it's a real problem for me 🙂 However, if I needed to send many messages to a channel/actor asynchronously, setting a large channel capacity +
offer
would be the first thing I'd think about. I tried
launch(parent-context) { ch.send(..) }
, but it's very slow.
g

groostav

06/16/2017, 5:51 PM
vaskir: why not use an
UNLIMITED
size that gives you a linked-list channel?
v

vaskir

06/16/2017, 5:52 PM
because I didn't know about it at that time 🙂
btw, do channels use an array by default? How does it even work?..
I mean how messages deleted from it efficiently?
g

groostav

06/16/2017, 6:23 PM
I really dont know, but notice that it does have a
Head
pointer, so my guess is that it acts as a circular buffer, meaning "removal" is probably just
array[head] = null; head = head + 1 % size
v

vaskir

06/16/2017, 7:01 PM
ah, I see. That's great.
2 Views