janvladimirmostert
12/10/2022, 11:50 PMPossibly blocking call in non-blocking context could lead to thread starvation
Dispatchers.IO somehow manages to make such warnings go away, I want to make those warnings go away for my custom dispatcher too
launch(Dispatchers.CUSTOM) {
println(Thread.currentThread())
Thread.sleep(5_000) <<-- warning: Possibly blocking call ...
delay(5_000)
println("done!!!")
}
Riccardo Lippolis
12/11/2022, 9:18 AM@BlockingExecutor
annotation that sounds like the thing you need. I haven't actually tried it to see if it fixes the IntelliJ warning, but it would surprise me if it didn't 😅 : https://javadoc.io/doc/org.jetbrains/annotations/latest/org/jetbrains/annotations/BlockingExecutor.htmljanvladimirmostert
12/11/2022, 9:24 AMRemi Latapy
01/30/2023, 10:04 AMjanvladimirmostert
01/30/2023, 10:07 AMval Dispatchers.LOOM: @BlockingExecutor CoroutineDispatcher
get() = Executors.newVirtualThreadPerTaskExecutor().asCoroutineDispatcher()
janvladimirmostert
01/30/2023, 10:08 AMRemi Latapy
01/30/2023, 7:05 PM