jw
07/30/2019, 3:34 PMContinuation in the same stack frame? or is that just a best-practice thing to avoid blowing the stack?Dominaezzz
07/30/2019, 3:38 PMjw
07/30/2019, 3:39 PMsuspendCoroutine. I mean the Continuation parameter that is passed directly in bytecode.jw
07/30/2019, 3:40 PMCORUTINE_SUSPENDEDjw
07/30/2019, 3:40 PMDominaezzz
07/30/2019, 3:40 PMDominaezzz
07/30/2019, 3:43 PMContinuation in any stackframe has to be valid.Dominaezzz
07/30/2019, 3:44 PMjw
07/30/2019, 3:45 PMsuspendContinuation throwing a checked exception synchronously that was supplied to its Continuation in a seemingly-asynchronous wayjw
07/30/2019, 3:45 PMjw
07/30/2019, 3:45 PMDominaezzz
07/30/2019, 3:46 PMjw
07/30/2019, 3:47 PMDominaezzz
07/30/2019, 3:49 PMjw
07/30/2019, 3:50 PMMarko Mitic
07/30/2019, 4:00 PMIlmir Usmanov [JB]
07/30/2019, 4:35 PMSeems like it would create an invalid stateLet the function be
foo.
BaseContinuationImpl.resumeWith calls Continuation.invokeSuspend, which calls foo. Since you are using the same continuation object in recursive call, after the call's completion, BaseContinuationImpl.resumeWith calls completion.resumeWith, effectively dropping the frames (since recursion is unrolled).
At first glance, I see no harm in resuming at the same frame.Ilmir Usmanov [JB]
07/30/2019, 4:44 PMIlmir Usmanov [JB]
07/30/2019, 4:47 PMDico
07/30/2019, 4:57 PMDico
07/30/2019, 4:58 PMjw
07/31/2019, 12:39 PMelizarov
07/31/2019, 1:38 PMsuspendCoroutine with intrinsic version without protection. It is Ok to race it with resumption from another thread: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.coroutines.intrinsics/suspend-coroutine-unintercepted-or-return.htmlelizarov
07/31/2019, 1:39 PMjw
07/31/2019, 1:41 PMsuspendCancellableCoroutine which I don't think has an equivalent, right? I had to hand-wave over some stuff or the post would have been twice as long.elizarov
07/31/2019, 3:44 PM