Package-level declarations

Types

Link copied to clipboard
typealias ConcurrentMutableMap<K, V> = co.touchlab.stately.collections.ConcurrentMutableMap<K, V>

A thread-safe MutableMap.

Link copied to clipboard
typealias ConcurrentMutableSet<T> = co.touchlab.stately.collections.ConcurrentMutableSet<T>

A thread-safe MutableSet.

Link copied to clipboard
expect class SafeLock : AutoCloseable

A Lock that can be closed safely even while another thread might still be using it.

actual class SafeLock : AutoCloseable

Lock is backed by java.util.concurrent.locks.ReentrantLock on the JVM and Android. There is no native resource to free, so close() there is a no-op only flipping closed.

actual class SafeLock : AutoCloseable

On Linux and mingw, Lock.close() calls pthread_mutex_destroy unconditionally. That is undefined behavior while another thread is still locking or unlocking it. Stately's Lock does not check for this, which caused test failures on Linux. Apple and mingw silently ignore the same misuse.

actual class SafeLock : AutoCloseable

JS and wasmJs are single-threaded. There is nothing to actually lock. Only the closed check remains meaningful.

Functions

Link copied to clipboard
inline fun <T> SafeLock.withLock(block: () -> T): T

Runs block with this lock held.