Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiplatform synchronization (Use kotlinx-atomicfu) #5552

Open
westnordost opened this issue Mar 25, 2024 · 1 comment
Open

Multiplatform synchronization (Use kotlinx-atomicfu) #5552

westnordost opened this issue Mar 25, 2024 · 1 comment
Labels
iOS necessary for iOS port

Comments

@westnordost
Copy link
Member

westnordost commented Mar 25, 2024

synchronized is a JVM-only API in Kotlin and as far as we know, there are no plans to change that.

synchronized is used in StreetComplete in many places in the data layer. The data layer is architecture-wise a blocking API (i.e. no coroutines, no suspending functions) and hence we can't use Mutex for threadsafe locks. (Let's not preclude that we refactor the data layer one day to be coroutine-based although it would be a considerable effort, but for now:)

We need a multiplatform replacement for synchronized. The most obvious choice is the official kotlinx-atomicfu, which is however still marked as experimental, especially the locks.
So, while there are other things to do in preparation of #5412, it might be better to hold off towards (at least) merging a PR that implements this (because according to one maintainer of kotlinx-atomicfu, they are working towards stabilization)

@westnordost westnordost added the iOS necessary for iOS port label Mar 25, 2024
@westnordost
Copy link
Member Author

Note that kotlinx-atomicfu's API is marked as having an unstable API, i.e. may change from release to release. The functionality of the library itself can be considered stable, though, it is used by other core kotlinx libraries.

I read somewhere that the maintainer(s) are working on stabilizing the API. So, it may be worth on holding off on this while there are other things to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
iOS necessary for iOS port
Projects
Status: Blocked
Development

No branches or pull requests

1 participant