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.