package net.sergeych.synctools import kotlinx.atomicfu.locks.ReentrantLock /** * Get the platform-depended implementation of a mutex. It does nothing in the * browser and use appropriate mechanics on JVM and native targets. See * [ProtectedOpImplementation.invoke], [ProtectedOpImplementation.withLock] * ```kotlin * val op = ProtectedOp() * //... * op { * // mutually exclusive execution * println("sequential execution here") * } * ~~~ */ actual fun ProtectedOp(): ProtectedOpImplementation = object : ProtectedOpImplementation { private val access = ReentrantLock() override fun lock() { access.lock() } override fun unlock() { access.unlock() } }