fix of tests

This commit is contained in:
InsanusMokrassar 2024-08-03 01:47:39 +06:00
parent 95d2f6de01
commit c79c20033c
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 * Do lock in [readSemaphore] inside of [writeMutex] locking
*/ */
suspend fun acquireRead() { suspend fun acquireRead() {
_writeMutex.waitUnlock()
_readSemaphore.acquire() _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 * Locking [writeMutex] and wait while all [readSemaphore] permits will be freed
*/ */
suspend fun lockWrite() { suspend fun lockWrite() {
_readSemaphore.acquire(readPermits)
_writeMutex.lock() _writeMutex.lock()
_readSemaphore.acquire(readPermits)
} }
/** /**

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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