suspend 函数内部的 runBlocking 调用。
在 suspend 函数中使用 runBlocking 会否定挂起机制,阻塞调用线程,并破坏异步编程的核心目的。
该快速修复会根据上下文,自动将 runBlocking 替换为以下选项之一:
run 调用。CoroutineContext 的情况下的 withContext 调用。示例:
suspend fun something() {
runBlocking {
code() // 线程在此处被阻塞
}
}
在应用快速修复后:
suspend fun something() {
runBlocking {
code() // 异步运行
}
}
2025.1 的新功能