With coroutines yet to be released for iOS, what i...
# kotlin-native
t
With coroutines yet to be released for iOS, what is the proper way in common code for 1) cross-thread access for some models (not simple stateless objects) 2) thread switching (ui->bg->ui) I want to achieve something like
Copy code
fun search(query: String, model: SearchModel, view: SearchView): Job {
        val cancellableJob = launch(CommonPool) {
            val data = model.search(query) // (1)
            withContext(UI) {
                view.showData(data) (2)
            }
        }
        return cancellableJob
    }
r
You can always try wrapping your favorite native iOS async APIs in expect/actual declarations
t
I've already done 2) with async_dispatch, but 1) is still needed
m
For global states the only known workaroud is using C interop: https://github.com/JetBrains/kotlin-native/tree/master/samples/globalState
And maybe
konan.worker.AtomicReference
t
AtomicReference
differs from JVM (at least fqdn), but doesn't work properly for non-objects (but I'm still researching)
m
For simple numbers there are
AtomicInt
and
AtomicLong
t
I need at least a list of objects
meh, forgot about
initRuntimeIfNeeded()
again 😞
m
I think it should be something like
RCU
in linux kernel https://m.habr.com/post/206984/