Paul Woitaschek
07/01/2021, 12:18 PMpublic fun runTest(suspending: SuspendingInterface) {
CoroutineScope(Dispatchers.Default).launch {
println(suspending.value())
}
}
public interface SuspendingInterface {
public suspend fun value(): Int
}
And ios switches threads:
class SuspendingInterfaceImpl : SuspendingInterface{
func value(completionHandler: @escaping (KotlinInt?, Error?) -> Void) {
DispatchQueue.global().async {
completionHandler(42, nil)
}
}
}
CoroutineTest.runTest(SuspendingInterfaceImpl())
That directly fails with:
kotlin.native.IncorrectDereferenceException: illegal attempt to access non-shared kotlinx.coroutines.internal.DispatchedContinuation@1f67dc8 from other thread
borisdamato
07/01/2021, 12:24 PM-native-mt
version of coroutines? https://kotlinlang.org/docs/mobile/concurrency-and-coroutines.html#multithreaded-coroutinesPaul Woitaschek
07/01/2021, 12:24 PMJohan Nenzén
07/05/2021, 6:21 PMPaul Woitaschek
07/05/2021, 6:22 PMJohan Nenzén
07/05/2021, 6:24 PMPaul Woitaschek
07/05/2021, 7:05 PMJohan Nenzén
07/05/2021, 8:05 PM