Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

1. Callback interop

I was expecting something like call/cc, or `suspend(Cancellable)Coroutine` in Kotlin. But judging from the list of preview items[1] it seems the only way is to have the callback write the result to a Future and blocking wait on it.

2.1 Promise.all() can be done with `.map(future => future.get())` But it is a bit more complicated than that. [2]

2.2 Promise.any()

This is somewhat relevant http://mail.openjdk.java.net/pipermail/loom-dev/2020-Februar...

[1] https://download.java.net/java/early_access/loom/docs/api/pr...

[2] https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutin... "This function is not equivalent to deferreds.map { it.await() } which fails only when it sequentially gets to wait for the failing deferred, while this awaitAll fails immediately as soon as any of the deferreds fail."



Thanks!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: