temporal realization of SmartKeyRWLocker

This commit is contained in:
2025-03-22 16:01:59 +06:00
parent 4b7d65e8b4
commit 4c9e435df8
3 changed files with 171 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import kotlinx.coroutines.withTimeout
import kotlin.time.Duration
suspend fun <T> realWithTimeout(time: Duration, block: suspend () -> T): T {
return withContext(Dispatchers.Default.limitedParallelism(1)) {
withTimeout(time) {
block()
}
}
}