https://kotlinlang.org logo
#coroutines
Title
# coroutines
m

mzgreen

01/05/2020, 6:14 PM
Copy code
GlobalScope.async {
    while (isActive) {
        println("test")
    }
}
This works on Android and jvm but doesn’t work on iOS. I don’t get any error, it just doesn’t do anything. Is it possible to make it work somehow?
GlobalScope.launch(context = <http://Dispatchers.IO|Dispatchers.IO>)
would be fine too I guess but I can’t see
<http://Dispatchers.IO|Dispatchers.IO>
on iOS 🤔
o

octylFractal

01/05/2020, 6:23 PM
m

mzgreen

01/05/2020, 6:27 PM
Oh.. so it's notnsupported yet.. thank you for the link. I think I saw a tweet from @kpgalligan saying that he was able to make it work in his iOS app 🤔
k

kpgalligan

01/05/2020, 6:30 PM
I haven’t been doing anything with GlobalScope, so I don’t know about that. For iOS, if you use the production version of coroutines, they’re single threaded and have other restrictions. There’s a draft PR with support for multiple threads.
There is a preview version of coroutines published that you can try out:
Copy code
1.3.3-native-mt
We’re using that with some almost-production code.
m

mzgreen

01/05/2020, 6:37 PM
I'll try that, thanks!
9 Views