pniederw
02/09/2017, 3:44 AMdefer to async, will you also rename future back to async?elizarov
02/09/2017, 5:54 AMasync and future return different future classes. async result type is Deferred, while future result type is CompletableFuture. They cannot both have the same name. Which one to call async then? The one that returns Deferred, of course, because it works anywhere (including any Android version), while CompletableFuture is only available on JDK8 and latest Androids.pniederw
02/09/2017, 5:55 AMelizarov
02/09/2017, 5:59 AMasync (different libs might want to use different futures), but we'd rather nudge people into using this particular implementation of futures, since it does not have any blocking operations (better for coroutines -- less error-prone), has clear exception-transparency semantics, supports laziness, and will work with upcoming selectpniederw
02/09/2017, 6:05 AMCompletableFuture. that’s my perspective on this topic.pniederw
02/09/2017, 6:11 AMelizarov
02/09/2017, 6:19 AMelizarov
02/09/2017, 6:22 AMasync.pniederw
02/09/2017, 6:33 AMsuspend fun <S, T> Iterable<S>.runConcurrently(action: suspend S.() -> T): Collection<T>pniederw
02/09/2017, 6:34 AMasyncelizarov
02/09/2017, 6:34 AMkotlinx.coroutines, toopniederw
02/09/2017, 6:35 AMsuspend fun <S, T> (suspend () -> S).runConcurrentlyWith(action: suspend () -> T): Pair<S, T>pniederw
02/09/2017, 6:37 AMsuspendingFunction { … }.runConcurrentlyWith { … }pniederw
02/09/2017, 6:38 AMsuspendingFunction to make the type system understand that the lambda is a suspending lambda.pniederw
02/09/2017, 6:38 AMsuspend fun <T> suspendingFunction(f: suspend () -> T): suspend () -> T = felizarov
02/09/2017, 6:45 AMcoroutine { one() } pairWith coroutine { two() } // result is Pair<A,B>
or
collection.map { coroutine { process(it) } }.all() // result is `List<T>`pniederw
02/09/2017, 6:53 AMpniederw
02/09/2017, 6:55 AMfun Iterable<CompletableFuture>.await().pniederw
02/09/2017, 6:56 AMelizarov
02/09/2017, 7:21 AM