fix of tests

This commit is contained in:
InsanusMokrassar 2024-08-03 01:47:39 +06:00
parent 5fbc1a132f
commit bf293a8f8f
8 changed files with 93 additions and 19 deletions

View File

@ -23,6 +23,7 @@ class SmartRWLocker(private val readPermits: Int = Int.MAX_VALUE, writeIsLocked:
* Do lock in [readSemaphore] inside of [writeMutex] locking
*/
suspend fun acquireRead() {
_writeMutex.waitUnlock()
_readSemaphore.acquire()
}
@ -37,8 +38,8 @@ class SmartRWLocker(private val readPermits: Int = Int.MAX_VALUE, writeIsLocked:
* Locking [writeMutex] and wait while all [readSemaphore] permits will be freed
*/
suspend fun lockWrite() {
_readSemaphore.acquire(readPermits)
_writeMutex.lock()
_readSemaphore.acquire(readPermits)
}
/**

View File

@ -12,8 +12,20 @@ kotlin {
}
}
js (IR) {
browser()
nodejs()
browser {
testTask {
useMocha {
timeout = "60000"
}
}
}
nodejs {
testTask {
useMocha {
timeout = "60000"
}
}
}
}
androidTarget {
publishAllLibraryVariants()

View File

@ -12,8 +12,20 @@ kotlin {
}
}
js (IR) {
browser()
nodejs()
browser {
testTask {
useMocha {
timeout = "60000"
}
}
}
nodejs {
testTask {
useMocha {
timeout = "60000"
}
}
}
}
androidTarget {
publishAllLibraryVariants()
@ -36,7 +48,7 @@ kotlin {
}
commonTest {
dependencies {
implementation kotlin('test-common')
implementation kotlin('test')
implementation kotlin('test-annotations-common')
implementation libs.kt.coroutines.test
}

View File

@ -12,8 +12,20 @@ kotlin {
}
}
js (IR) {
browser()
nodejs()
browser {
testTask {
useMocha {
timeout = "60000"
}
}
}
nodejs {
testTask {
useMocha {
timeout = "60000"
}
}
}
}
androidTarget {
publishAllLibraryVariants()

View File

@ -12,8 +12,20 @@ kotlin {
}
}
js (IR) {
browser()
nodejs()
browser {
testTask {
useMocha {
timeout = "60000"
}
}
}
nodejs {
testTask {
useMocha {
timeout = "60000"
}
}
}
}
linuxX64()
mingwX64()

View File

@ -12,8 +12,20 @@ kotlin {
}
}
js (IR) {
browser()
nodejs()
browser {
testTask {
useMocha {
timeout = "60000"
}
}
}
nodejs {
testTask {
useMocha {
timeout = "60000"
}
}
}
}
linuxX64()
mingwX64()

View File

@ -12,8 +12,20 @@ kotlin {
}
}
js (IR) {
browser()
nodejs()
browser {
testTask {
useMocha {
timeout = "60000"
}
}
}
nodejs {
testTask {
useMocha {
timeout = "60000"
}
}
}
}
androidTarget {
publishAllLibraryVariants()

View File

@ -126,14 +126,15 @@ fun <Key, Value> WriteKeyValueRepo<Key, Value>.caching(
) = FullWriteKeyValueCacheRepo(this, kvCache, scope)
open class FullKeyValueCacheRepo<Key,Value>(
protected open val parentRepo: KeyValueRepo<Key, Value>,
override val parentRepo: KeyValueRepo<Key, Value>,
kvCache: KeyValueRepo<Key, Value>,
scope: CoroutineScope = CoroutineScope(Dispatchers.Default),
skipStartInvalidate: Boolean = false,
locker: SmartRWLocker = SmartRWLocker(writeIsLocked = !skipStartInvalidate),
) : FullWriteKeyValueCacheRepo<Key,Value>(parentRepo, kvCache, scope),
) : //FullWriteKeyValueCacheRepo<Key,Value>(parentRepo, kvCache, scope),
KeyValueRepo<Key,Value>,
ReadKeyValueRepo<Key, Value> by FullReadKeyValueCacheRepo(
WriteKeyValueRepo<Key,Value> by parentRepo,
FullReadKeyValueCacheRepo<Key, Value>(
parentRepo,
kvCache,
locker
@ -170,7 +171,7 @@ open class FullKeyValueCacheRepo<Key,Value>(
override suspend fun set(toSet: Map<Key, Value>) {
locker.withWriteLock {
super.set(toSet)
parentRepo.set(toSet)
kvCache.set(
toSet.filter {
parentRepo.contains(it.key)
@ -181,7 +182,7 @@ open class FullKeyValueCacheRepo<Key,Value>(
override suspend fun unset(toUnset: List<Key>) {
locker.withWriteLock {
super.unset(toUnset)
parentRepo.unset(toUnset)
kvCache.unset(
toUnset.filter {
!parentRepo.contains(it)