bnn
03/24/2022, 2:03 AMdelay
function call which is used inside the Library implementation never complete. As a result, Future.get() blocks forever.
I know it’s not recommended to call Future.get() is not recommended practice. But, I would like to avoid this issue because it’s too disastrous given library clients has no idea if the delay
suspend function is used under the hood.
The following is the complete example code that reproduces the issue.
https://gist.github.com/bananaumai/da23494ed2ba1d22c39af23a7c07ba2f#file-mainactivity-kt
Any advise and/or recommendation would be appreciated.
Thanks in advance.Nick Allen
03/24/2022, 2:34 AMdelay
. Any async library that uses the main thread would be blocked by someone calling Future.get()
on the main thread.
I don't think it's reasonable to assume that a Android library does not use the main thread.call Future.get() is not recommended practice"not recommended" is a bit of an understatement when it comes to blocking calls on the main thread.
bnn
03/24/2022, 3:01 AMNick Allen
03/24/2022, 3:07 AMDelay
interface) then a special executor is created specifically for delays.
It's open source so when docs aren't enough, you can always dig through the source code.bnn
03/24/2022, 10:43 AMI’m guessing on JVM you either don’t have a main thread (you just use main) or, if you do, you are not calling get() on the main thread.Okay. Just for clarification. It was running in the main thread.
If there’s no main dispatcher (or it doesn’t implement the internalinterface) then a special executor is created specifically for delays.Delay
It’s open source so when docs aren’t enough, you can always dig through the source code.Sure. I’ll be looking into it. Thanks.
Adam Powell
03/24/2022, 2:31 PMbnn
03/24/2022, 11:48 PM