From 6e2297e06979437531155c62a4f5fbbe6ab06ebc Mon Sep 17 00:00:00 2001 From: Kevin Galligan Date: Fri, 28 Aug 2020 11:39:57 -0400 Subject: [PATCH] Ktor update --- topics/concurrency-and-coroutines.md | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/topics/concurrency-and-coroutines.md b/topics/concurrency-and-coroutines.md index df1e035..4b786d6 100644 --- a/topics/concurrency-and-coroutines.md +++ b/topics/concurrency-and-coroutines.md @@ -156,8 +156,8 @@ commonMain { } ``` -When using other libraries that also depend on `kotlinx.coroutines`, such as Ktor, make sure that they use the single-threaded -version of `kotlinx-coroutines` that works for all platforms. You can do this with `strictly`: +When using other libraries that also depend on `kotlinx.coroutines`, such as Ktor, make sure to specify the multithreaded version +of `kotlinx-coroutines`. You can do this with `strictly`: ```kotlin implementation ("org.jetbrains.kotlinx:kotlinx-coroutines-core:%coroutinesVersion%-native-mt"){ @@ -177,17 +177,6 @@ If you see `InvalidMutabilityException` related to a coroutine operation, it's v See a [complete example of using multithreaded coroutines in a KMM application](https://github.com/touchlab/KaMPKit). -### Ktor and coroutines - -Follow these guidelines when integrating Ktor into your project: - -* Make sure that you use the single-threaded version of `kotlinx.coroutines` as a dependency for Ktor. Ktor -for macOS and iOS requires this version. -* Make calls to Ktor from the main thread. -* If you're going to use Ktor and coroutines that cross threads, keep a separate `CoroutineScope` for Ktor. As a more complex -alternative, you can create a child `CoroutineScope` with an isolated `Job`. If `Job` gets frozen, Ktor will stop working. -See [this example](https://github.com/touchlab/KaMPKit/blob/master/shared/src/iosMain/kotlin/co/touchlab/kampkit/ktor/Platform.kt#L13) for details. - ## Alternatives to `kotlinx-coroutines` There are a few alternative ways to run parallel code.