Dispatchers IO is now considered non-blocking context
See BlockingMethodInNonBlockingContextInspection
This commit is contained in:
committed by
Mikhail Glukhikh
parent
3b33d3e58d
commit
297054037c
@@ -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()
|
||||
}
|
||||
Reference in New Issue
Block a user