Blocking Call In Suspend (ARCH8028)
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
Key kotlin.async.blocking-call-in-suspend · Severity error · Category async
Flags Thread.sleep, Future.get and other thread-blocking calls inside suspend functions - they freeze the dispatcher thread instead of suspending.
Incorrect
Section titled “Incorrect”suspend fun poll() { Thread.sleep(1000) val v = future.get()}Correct
Section titled “Correct”suspend fun poll() { delay(1000) val v = future.await()}Use delay(), await(), or wrap unavoidable blocking IO in withContext(Dispatchers.IO).