Is there a better way to implement suspending `whi...
# coroutines
a
Is there a better way to implement suspending
while
loop instead of this?
Copy code
while (condition) {
   ...
   delay(1)
}
s
Hard to tell without knowing what the loop is for
a
I have blocking function
getFromQueue
that in loop tries to get something from a concurrent queue until there is something. If there is nothing it tries again. I've just figured out I can do a generator instead of
getFromQueue
.
s
Yup, then there is no need to call
delay(....)
or
yield()
.
a
Thank you.
d
You can also use channel instead of queue
e
Yes a RENDEZVOUS
Channel
is somewhat analogous to your “blocking queue”
d
It would be more like an array channel
a
You can also use channel instead of queue
Great stuff.