If I have a KN library code that uses coroutines a...
# kotlin-native
p
If I have a KN library code that uses coroutines and I want to call that code for example from C, how would I initialize the event loop? Right now I am getting this error:`kotlin.IllegalStateException: There is no event loop. Use runBlocking { ... } to start one.`
If I call that library from Kotlin, I can just use
fun main() = runBlocking {...}
, but how would I call this with C code?
b
You'd need up create a function that calls runBlocking and then calls your coroutines code inside that
p
The problem is that this library is full of coroutine code. And I would like to avoid using runBlocking for each and every function. I guess I could just create an alias for runBlocking and then call everything inside that function but that would look pretty confusing to the developer who would have to use the library I think.
b
Generally, C doesn't support suspend, so I'm not sure how you avoid it
p
Yeah I was mainly asking if there is a solution for this already, since this may be a use case that could be very popular, because kotlin coroutines are basically supported on every platform now.
b
AFAIK, there isn't 😕
k
Workers are only form of coroutines implemented yet for K/N.