Downgrade coroutines until Kotlin 1.4

This commit is contained in:
Mygod
2020-07-18 03:41:50 +08:00
parent 07a63f77c1
commit a90df1b88c
2 changed files with 13 additions and 12 deletions

View File

@@ -95,7 +95,7 @@ dependencies {
implementation("com.takisoft.preferencex:preferencex-simplemenu:1.1.0")
implementation("eu.chainfire:librootjava:1.3.0")
implementation("org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.2")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.8")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.6")
testImplementation("junit:junit:4.13")
androidTestImplementation("androidx.room:room-testing:$roomVersion")
androidTestImplementation("androidx.test:runner:1.2.0")

View File

@@ -476,34 +476,35 @@ class RootServer @JvmOverloads constructor(private val warnLogger: (String) -> U
cancellables[callback] = { commandJob.cancel() }
defaultWorker.launch(commandJob) {
val result = try {
val result = command.execute();
{ output.pushResult(callback, result) }
val result = command.execute()
withContext(callbackWorker + NonCancellable) { output.pushResult(callback, result) }
} catch (e: Throwable) {
{ output.pushThrowable(callback, e) }
}
withContext(callbackWorker + NonCancellable) { output.pushThrowable(callback, e) }
} finally {
cancellables.remove(callback)
withContext(callbackWorker + NonCancellable) { result() }
}
}
}
is RootCommandChannel<*> -> defaultWorker.launch {
val result = try {
try {
coroutineScope {
command.create(this).also {
cancellables[callback] = { it.cancel() }
}.consumeEach { result ->
withContext(callbackWorker) { output.pushResult(callback, result) }
}
};
@Suppress("BlockingMethodInNonBlockingContext") {
}
@Suppress("BlockingMethodInNonBlockingContext")
withContext(callbackWorker + NonCancellable) {
output.writeByte(CHANNEL_CONSUMED)
output.writeLong(callback)
output.flush()
}
} catch (e: Throwable) {
{ output.pushThrowable(callback, e) }
}
withContext(callbackWorker + NonCancellable) { output.pushThrowable(callback, e) }
} finally {
cancellables.remove(callback)
withContext(callbackWorker + NonCancellable) { result() }
}
}
is Shutdown -> break@loop
else -> throw IllegalArgumentException("Unrecognized input: $command")