function from a library. The problem is the lambda is not suspend-aware. Is there any way to call a suspend fn in the lambda there other than calling runBlocking? FWIW, this is all inside a suspending function, so I do not want to do
runBlocking
inside a
suspend
function. It just feels so wrong.
n
nanodeath
10/02/2020, 2:40 PM
so to be clear, your the containing function has
suspend
, the
open
function callback is not
suspend
, and you want to be able to call other
suspend
methods from inside the callback?
p
Phani Mahesh
10/02/2020, 2:40 PM
Yes.
a
Adam Powell
10/02/2020, 2:52 PM
Why do you want to suspend while reading a file from a blocking reader API?
p
Phani Mahesh
10/02/2020, 2:54 PM
I was using the library wrong, I just realized I can readAsSequence inside the open lambda, get the sequence out, and process it as I want in the suspending context out of the blocking callback to open. Thanks @Adam Powell!
Phani Mahesh
10/02/2020, 3:02 PM
Actually that won't work because the stream is closed outside the lambda, and reading from sequence fails. Oh well. I found we have the author and a (small) community hanging around in #CMAL3470A, moving this there