Is it correct to use `yield()` for interfacing non...
# coroutines
Is it correct to use
for interfacing non-blocking functions from an external library? Like this example code:
Copy code
while (...) {
    val r: Int = nonBlockingFunction() // Returns -1 if no data available
    if (r == -1) {
        yield() // Is this a correct way to "wait" in the coroutine?
    } else {
        ... // Do something with the data
while (true) yield()
will allow other coroutines to run, but it always returns to the back of the runqueue so you'll spin 100% of CPU doing it. in general, I would not call that "correct"
I see... what do you recommend? Calling
instead does not seem "reactive" enough.
a non-blocking API must have some way to notify you when it's actually ready