Call for feedback/input I want to introduce an `a...
# kovenant
m
Call for feedback/input I want to introduce an
await
construct to Kovenant, but this is actually really tricky. The expected behaviour of an
await
call in most languages is not to block but to let the calling thread do other work and continue later. Otherwise we just could make a call to
get()
(which does block). Furthermore, blocking shouldn’t be done inside a
async
block since you can create a deadlock situation that way. So this is what we want:
Copy code
async {
    val a1 = await(p1)
    val a2 = await(p2(a1))
    //...etc
}
The tricky part is the implementation of
await
itself. It should give control back to the Dispatcher. The easiest way is to introduce a method on Dispatchers to help along and do one task from the queue. But not all dispatchers can be made to help along. If you create a Dispatcher from e.g. an Executor you won’t always be able to provide such method. I think in that case await should throw some Unsupported Operation Exception. But that is not really user friendly. What do you think?