Package-level declarations

Types

Link copied to clipboard
class KeyedMutex<K>

A keyed, suspend-friendly mutex for Kotlin Multiplatform.

Link copied to clipboard
class RWLock

A Kotlin Multiplatform read-write lock that allows concurrent read access while guaranteeing exclusive write access.

Functions

Link copied to clipboard
inline suspend fun <K, T> KeyedMutex<K>.withLock(key: K, owner: Any? = null, action: suspend () -> T): T

Convenience function mirroring Mutex.withLock

Link copied to clipboard
suspend fun Mutex.withLockCheck(check: () -> Boolean, message: () -> String, action: suspend () -> Unit)

Executes the given action within a lock provided by the Mutex. Before acquiring the lock, it checks a condition specified by check. If the condition is satisfied, the lock is not acquired, and the operation returns early after logging a message provided by message. If the condition is not satisfied, the lock is acquired, the condition is rechecked, and if still not satisfied, the action is executed.