Dispatchers IO is now considered non-blocking context

See BlockingMethodInNonBlockingContextInspection
This commit is contained in:
Nikita Katkov
2018-12-06 16:59:15 +03:00
committed by Mikhail Glukhikh
parent 3b33d3e58d
commit 297054037c
5 changed files with 42 additions and 10 deletions
@@ -2,7 +2,6 @@
import kotlin.coroutines.*
import org.jetbrains.annotations.BlockingContext
import kotlin.coroutines.experimental.buildSequence
import java.lang.Thread.sleep
suspend fun testFunction() {
@@ -0,0 +1,28 @@
@file:Suppress("UNUSED_PARAMETER")
package kotlinx.coroutines
import java.lang.Thread.sleep
suspend fun withIoDispatcher() {
withContext(Dispatchers.IO) {
//no warning since IO dispatcher type used
Thread.sleep(42)
}
withContext(Dispatchers.Default) {
Thread.<warning descr="Inappropriate blocking method call">sleep</warning>(1)
}
}
class CoroutineDispatcher()
object Dispatchers {
val IO: kotlinx.coroutines.CoroutineDispatcher = TODO()
val Default: kotlinx.coroutines.CoroutineDispatcher = TODO()
}
suspend fun <T> withContext(
context: CoroutineDispatcher,
f: suspend () -> T
) {
TODO()
}