https://kotlinlang.org logo
#coroutines
Title
# coroutines
c

carbaj0

08/19/2019, 8:49 AM
At some point in time startRetrieveCall will change the value of isAttempting. How can I wait for the condition to be fulfilled without having to make a recursive call?
Copy code
tailrec suspend fun call() : SomeObject =
        if (!isAttempting)
            startRetrievingCall()
        else
            call()
o

octylFractal

08/19/2019, 9:08 AM
Mutex
maybe? lock the mutex before
startRetrievingCall
, then lock it again after the call. This will suspend. In
startRetrievingCall
, at some point unlock the mutex, which will resume the original
call
point. Though to be honest, this looks like an XY situation, and you might be better served by
async
+
Deferred
, or a
Channel
c

carbaj0

08/19/2019, 12:13 PM
After investigating all the options I think Mutex is the solution
thanks
4 Views