Sam Garfinkel
04/03/2020, 4:51 PMstart = CoroutineStart.LAZY
:
val deferred = scope.async(start = CoroutineStart.LAZY) { "hello" }
val future = deferred.asCompletableFuture()
future.get() // Not sure this will actually cause the deferred to be evaluated
Esau Betancourt
04/03/2020, 5:15 PMCompletableFuture
future{
}.await(()
octylFractal
04/03/2020, 6:13 PMasCompletableFuture()
doesn't work with LAZY is the same reason that the scope.future
call says:
* A value of [CoroutineStart.LAZY] is not supported
* (since `CompletableFuture` framework does not provide the corresponding capability) and
* produces [IllegalArgumentException].
asCompletableFuture()
just failed, since you could still manually start()
the deferred in kotlin... but maybe it deserves some documentationSam Garfinkel
04/03/2020, 6:15 PMval foo by lazy { scope.future { something.await() } }