Swift's concurrent tasks with Mutex similar to Kotlin's Coroutines
So I have the following Kotlin's sample code to work with async stuff by using Coroutines and I want to achieve the same with Swift:
Kotlin:
private val mutex = Mutex()
private suspend fun startConcurrentJobs() = coroutineScope {
launch {
asyncJob()
}
launch {
asyncJob()
}
}
private suspend fun asyncJob() {
subAsyncJob1() // this job can be called by different coroutines at the same time
mutex.withLock {
// this job is not allowed to be...