mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2026-01-03 03:49:23 +00:00
temporal realization of SmartKeyRWLocker
This commit is contained in:
12
coroutines/src/commonTest/kotlin/RealTimeOut.kt
Normal file
12
coroutines/src/commonTest/kotlin/RealTimeOut.kt
Normal 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()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user