runBlocking() in Kotlin Native projects
See original GitHub issueI’m using ktor in a Kotlin Native project. The common sub-project of my project depends on io.ktor:ktor-client:0.9.5-rc13
, which transitevly adds dependency on kotlinx-coroutines-core-common:0.26.1-eap13
. launch()
and async()
are available for my project, but runBlocking()
is not. Do I need to add dependency on any other library to the common sub-project to access runBlocking()
, or is it not available by desing?
Thank you in advance!
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
KMM on iOS: There is no event loop. Use runBlocking { ... } to ...
I'm trying to use coroutines in a Kotlin Multiplatform project. I'm not experienced ...
Read more >runBlocking - Kotlin
Runs a new coroutine and blocks the current thread until its completion. This function should not be used from a coroutine. It is...
Read more >Kotlin Native Coroutines runBlocking
I'm trying to investigate coroutines under Kotlin Native. However, the method runBlocking does not seem to be available.
Read more >Concurrency and coroutines - Kotlin
Check out Kotlin/Native memory management to learn about the new memory manager, ... val client = HttpClient() //Running in the main thread, ...
Read more >Share code on platforms - Kotlin
Share code among all platforms used in your project. ... the function runBlocking and is compiled for the JVM and the native targets....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If I’m not mistaken
kotlinx-coroutines-core-common
does not include runBlocking because it define the common interface to all platforms and the Kotlin/JS platform does not support runBlocking, so it’s not included. You need to addkotlinx-coroutines-core-native
to your dependencies to use runBlocking@SeekDaSky
kotlinx-coroutines-core-native
can only be used with Kotlin Native compiler, which includes basic Kotlin Native project or the Native part of an MPP, this part was clear to me. What was not fully clear is ifkotlinx-coroutines-core
could be used in a common subproject of an MPP. Now it is fully clear that it can’t be used, so the lack ofrunBlocking()
inkotlinx-coroutines-core-common
is by design. Thank you, this helps.