Hey :) Does anybody know if we can use coroutines ...
# kotlin-native
w
Hey :) Does anybody know if we can use coroutines in native projects yet? Or rather has anyone actually done it before and could point me to some documentation on how to include it?
😎 1
g
Coroutines already part of the language, no need to include them. But kotlinx.coroutines (library with higher level primitives for coroutines) not available yet for Kotlin/Native. You can check this EchoServer sample that uses coroutines for async socket operations: https://github.com/JetBrains/kotlin-native/blob/master/samples/nonBlockingEchoServer/src/main/kotlin/EchoServer.kt
w
Aah nice! That explains why my compiler recognized the suspend keyword but not the
launch { }
function. Thanks
g
This is full API of coroutines that available as part of the language http://kotlinlang.org/api/latest/jvm/stdlib/kotlin.coroutines.experimental/index.html All other stuff, like
launch
,
async
,
Channels
etc are just library functions, these particular APIs a part of kotlinX.coroutines library https://github.com/Kotlin/kotlinx.coroutines