SmartMutex

sealed interface SmartMutex(source)

It is interface which will work like classic Mutex, but in difference have lockStateFlow for listening of the SmartMutex state.

There is Mutable and Immutable realizations. In case you are owner and manager current state of lock, you need Mutable. Otherwise, Immutable.

Any Mutable may produce its Immutable variant which will contains lockStateFlow equal to its Mutable creator

Inheritors

Types

Link copied to clipboard
class Immutable(val lockStateFlow: StateFlow<Boolean>) : SmartMutex

Immutable variant of SmartMutex. In fact will depend on the owner of lockStateFlow

Link copied to clipboard
class Mutable(locked: Boolean = false) : SmartMutex

Mutable variant of SmartMutex. With that variant you may lock and unlock. Besides, you may create Immutable variant of this instance with immutable factory

Properties

Link copied to clipboard
open val isLocked: Boolean
Link copied to clipboard
abstract val lockStateFlow: StateFlow<Boolean>

Functions

Link copied to clipboard

Will wait until the SmartMutex.lockStateFlow of this instance will be false.