تخطَّ إلى المحتوى

Blocking Call In Suspend (ARCH8028)

هذا المحتوى غير متوفر بلغتك بعد.

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.

suspend fun poll() {
Thread.sleep(1000)
val v = future.get()
}
suspend fun poll() {
delay(1000)
val v = future.await()
}

Use delay(), await(), or wrap unavoidable blocking IO in withContext(Dispatchers.IO).