spand
11/10/2020, 10:15 AMBig Chungus
11/10/2020, 10:28 AMspand
11/10/2020, 10:31 AMBig Chungus
11/10/2020, 10:51 AMsuspend fun myFun() {
someSuspendFun()
launch(<http://Dispatchers.IO|Dispatchers.IO>) { someBlockingFun() }
}
spand
11/10/2020, 10:56 AMBig Chungus
11/10/2020, 11:01 AMlouiscad
11/10/2020, 11:06 AM@Throws(IOException::class)
I think, it should be an okayish workaround.
@elizarov Do you think declaring potentially long blocking functions could land in Kotlin at some point?
I'd use a way to declare if a function does significant CPU work or blocking I/O. Such a thing could propagate similarly to @RequiresOptIn
annotated annotations (with warning or error), until stopped manually or automatically at the relevant dispatcher switch (using the invoke operator, withContext
or explicit dispatcher injection e.g. in a launch
call).CLOVIS
11/10/2020, 11:47 AMwithContext(IO)
?spand
11/10/2020, 11:52 AM@RequiesOptIn
wayCLOVIS
11/10/2020, 12:00 PMspand
11/10/2020, 12:07 PM