elizarov
01/22/2017, 8:37 AMfor().await().
and bar().await()
, and they could be in different methods. Like sometimes you have this big piece of business logic on your server (in Java) and it occasionally does some remote calls to other services here and there. Without coroutines you either do those calls blocking by invoking myRemoteCall()
(typical enterprise code) or if you have future-returning APIs then myRemoteCallAsync(...).get()
(blocking). This kind of code is notoriously hard to rewrite without blocking in Java. With coroutines you can change that kind of code in piece-meal fashion (method-by-method, class-by-class), replacing, at first, future-gets with myRemoteCallAsync().await()
and thus converting your particular function to non-blocking (suspending) implementation.