mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2026-10-23 21:30:39 +00:00
update dependencies
This commit is contained in:
@@ -32,7 +32,7 @@ class SmartKeyRWLocker<T>(
|
||||
require(globalLockerReadPermits > 0) { "The maximal number 'globalLockerReadPermits' of global permits on reading ($globalLockerReadPermits) must be positive." }
|
||||
require(perKeyReadPermits > 0) { "The maximal number 'perKeyReadPermits' of permits on reading per key ($perKeyReadPermits) must be positive." }
|
||||
}
|
||||
|
||||
|
||||
private val globalRWLocker: SmartRWLocker = SmartRWLocker(
|
||||
readPermits = globalLockerReadPermits,
|
||||
writeIsLocked = globalLockerWriteIsLocked
|
||||
|
||||
@@ -20,7 +20,7 @@ class SmartRWLocker(private val readPermits: Int = Int.MAX_VALUE, writeIsLocked:
|
||||
init {
|
||||
require(readPermits > 0) { "The maximal number 'readPermits' of permits on reading ($readPermits) must be positive." }
|
||||
}
|
||||
|
||||
|
||||
private val _readSemaphore = SmartSemaphore.Mutable(permits = readPermits, acquiredPermits = if (writeIsLocked) readPermits else 0)
|
||||
private val _writeMutex = SmartMutex.Mutable(locked = writeIsLocked)
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ sealed interface SmartSemaphore {
|
||||
require(acquiredPermits >= 0) { "The number 'acquiredPermits' of initially acquired permits ($acquiredPermits) must be non-negative." }
|
||||
require(permits >= acquiredPermits) { "The number 'acquiredPermits' of acquired initially permits ($acquiredPermits) must not exceed the maximal number 'permits' of permits ($permits)." }
|
||||
}
|
||||
|
||||
|
||||
override val maxPermits: Int = permits
|
||||
private val _freePermitsStateFlow = MutableRedeliverStateFlow<Int>(permits - acquiredPermits)
|
||||
override val permitsStateFlow: StateFlow<Int> = _freePermitsStateFlow.asStateFlow()
|
||||
|
||||
Reference in New Issue
Block a user