is there anything in the stdlib to take a Blocking...
# getting-started
k
is there anything in the stdlib to take a BlockingQueue and for-loop over it in a blocking fashion? Like take() would do, blocking when the queue is empty?
y
AFAIK you could create a sequence out of it like so:
Copy code
fun <T> BlockingQueue<T>.asSequence() = sequence<T> {
    while(true) {
        yield(take())
    }
}
This has the same exact behavior as calling
take
each time.
👌 2
🙏 1