question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

runBlocking() in Kotlin Native projects

See original GitHub issue

I’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:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
SeekDaSkycommented, Oct 7, 2018

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 add kotlinx-coroutines-core-native to your dependencies to use runBlocking

0reactions
yurirycommented, Oct 9, 2018

@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 if kotlinx-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 of runBlocking() in kotlinx-coroutines-core-common is by design. Thank you, this helps.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found