This commit is contained in:
Horis
2026-01-05 10:44:53 +08:00
parent 9a6e43c23b
commit 59a0cec2b1
@@ -200,11 +200,9 @@ class Coroutine<T>(
private suspend inline fun dispatchVoidCallback(scope: CoroutineScope, callback: VoidCallback) {
if (null == callback.context) {
withContext(scope.coroutineContext) {
callback.block.invoke(scope)
}
callback.block.invoke(scope)
} else {
withContext(scope.coroutineContext + callback.context) {
withContext(callback.context) {
callback.block.invoke(this)
}
}
@@ -219,7 +217,7 @@ class Coroutine<T>(
if (null == callback.context) {
callback.block.invoke(scope, value)
} else {
withContext(scope.coroutineContext + callback.context) {
withContext(callback.context) {
callback.block.invoke(this, value)
}
}
@@ -231,7 +229,7 @@ class Coroutine<T>(
timeMillis: Long,
noinline block: suspend CoroutineScope.() -> T
): T {
return withContext(scope.coroutineContext + context) {
return withContext(context) {
if (timeMillis > 0L) withTimeout(timeMillis) {
block()
} else {
@@ -242,12 +240,12 @@ class Coroutine<T>(
private data class Result<out T>(val value: T?)
private inner class VoidCallback(
private class VoidCallback(
val context: CoroutineContext?,
val block: suspend CoroutineScope.() -> Unit
)
private inner class Callback<VALUE>(
private class Callback<VALUE>(
val context: CoroutineContext?,
val block: suspend CoroutineScope.(VALUE) -> Unit
)