How stable is limitedParallelism in practice?

So far, to implement concurrency without parallelism (since individual tasks aren’t atomic and I rely on the cooperative multitasking nature of coroutines to control when tasks run), I use the JVM’s Executors.newSingleThreadExecutor() function, and call asCoroutineDispatcher on it to get a single-threaded dispatcher. limitedParallelism is new in Kotlin 1.6, and appears to be capable of providing me with the same functionality if I limit the parallelism to 1. However, it is still marked as experimental in Kotlin 1.7.

My question is: How unstable / risky is the current state of limitedParallelism in practice? I’d like to get rid of platform specific code in my Kotlin multiplatform project, and the dispatcher situation is the only one that remains unsolved.

1 Like

Have you checked the description of ExperimentalCoroutinesApi?

Roughly speaking, there is a chance that those declarations will be deprecated in the near future or the semantics of their behavior may change in some way that may break some code.

So it means that API may be changed, but usually it’s not an issue for applications, but maybe e an issue for libraries