v0ldem0rt
08/07/2018, 12:35 AMpakoito
08/07/2018, 12:52 AMgroostav
08/07/2018, 1:29 AMawait()
or select { onAwait
. I dont know if coroutines suspended on either of those methods are resumed in FIFO ordering, but if I had to guess I'd say they were, though of course if your not careful you're likely to get dispatched on the common-pool which will give you parallelism by default. The CompletableFuture
uses a reasonably simple CAS loop to `complete`: int his way, only one complete
(or completeExceptionally
) call will succeed. Note the API for complete
returns a boolean for success or failure.Deferred
which apply all sorts of local optimizations, but all of the ones I know about can be consumed from multiple coroutine calls to await()
.Vsevolod Tolstopyatov [JB]
08/07/2018, 11:09 AMoverhead (race conditions/thread safety)Overhead or correctness? 🙂 From the correctness perspective, everything is fine, multiple awaiters don’t affect deferred in any way. From the overhead perspective, there is some in case when
await
call suspends, but it’s negligiblebdawg.io
08/07/2018, 6:15 PMoverhead … same Deferred<T>@Vsevolod Tolstopyatov [JB] Is that overhead any different than awaiting on two different
Deferred<T>
instead of the same one?Vsevolod Tolstopyatov [JB]
08/07/2018, 6:56 PMbdawg.io
08/07/2018, 6:59 PMthere is some in case whenIs there any difference in overhead of calling the suspendingcall suspendsawait
await()
twice on the same Deferred<T>
vs on two different Deferred<T>
. Particularly to answer the overhead
part of the question of the OPVsevolod Tolstopyatov [JB]
08/07/2018, 7:00 PM