ConcurrencyUtils

Concurrency utilities for state management without external dependencies.

These utilities provide thread-safe operations using only Kotlin stdlib, making them coroutine-friendly without requiring coroutine dependencies.

Functions

Link copied to clipboard
fun <T> atomicUpdate(container: StateContainer<T>, updater: (T) -> T, maxRetries: Int = 10): StateUpdateResult<T>

Atomically updates state with retry logic for failed operations.

Link copied to clipboard
fun createAtomicFlag(initialValue: Boolean = false): AtomicBoolean

Creates a thread-safe flag for controlling operations.

Link copied to clipboard
fun <T> createAtomicReference(initialValue: T? = null): AtomicReference<T>

Creates a thread-safe reference holder.