https://kotlinlang.org logo
#coroutines
Title
# coroutines
e

elizarov

07/10/2017, 9:49 PM
@rogeralsing it is going to released in the next version of
kotlinx.coroutines
under the name of
CompletableDeferred
(unless we find something better) and is now available in
develop
branch.
🍻 3
r

rogeralsing

07/11/2017, 5:50 AM
elizarov: is there also some way to create a deferred from a result? .NET has Task.FromResult(...) making all code that awaits on such Task take the fast synchronous path
g

groostav

07/11/2017, 5:56 AM
I think I asked a similar question a while ago and I got a kind of interesting answer: coroutines deliberately dont have a "fast synchronous path", the idea basicallyb eing that if you API has aynchronous behaviour then it should either always run asynchronously or always run synchronously.
r

rogeralsing

07/11/2017, 7:07 AM
but what does that even mean? e.g. if suspend func Foo() calls suspend func Bar().. bar is just returning a value. e.g. 123... what does "run arcynchronously" mean in that context? will there be a yield upon calling Bar from Foo?
in .NET, that would have been a synchronous flow where the 123 is wrapped in a completed Task
g

groostav

07/11/2017, 5:29 PM
yeah I should say rogeralsing I've spent a fair bit of time with WPF so im pretty familiar with .net tasks --albeit when I was doing that C# 4 was new
ill see if i can dig up the article I was linked to and send it to you
9 Views