frankelot
12/16/2021, 6:29 PMsuspending fun
that puts something in a queue and suspends until that “something” gets its turn and is finished being processed.send()
suspends until the channel has buffer capacity and starts processing… not when its done processingNick Allen
12/16/2021, 6:54 PMMutex
frankelot
12/16/2021, 6:57 PMCasey Brooks
12/16/2021, 6:57 PMFlow
might be a better mechanism than raw channels, since by design the emitter will suspend until the collector has finished processing the itemfrankelot
12/16/2021, 6:57 PMNick Allen
12/16/2021, 6:57 PMCompleteableJob
in the item to signal when done but it’s easy to mess up error situations and you lose natural structured concurrencyfrankelot
12/16/2021, 7:04 PMmutex
and flows
and report back, thanks! for the helpThe purpose of channels is to make a “pipeline” of async communication. Putting an item into a channel and then waiting for processing to complete isn’t how they’re intended to be used, which is why it’s not working for you.this makes sense.. I don’t want async communication
darkmoon_uk
12/16/2021, 11:38 PMsuspendCoroutine
function e.g. in pseudocode:
fun queuedProcess(someParam: Param) = suspendCoroutine { continuation ->
addToQueue(param, continuation)
ensureQueueIsRunning()
}
...and elsewhere, the queue processing calls queueItem.continuation(result
)suspendCoroutine
suspends the execution at that point and gives you a Continuation
object that you can invoke with a result when you want that point of execution to continue. You can then store this object as part of your queued operation, and invoke it when the queued process completes.K Merle
12/17/2021, 5:35 AMCasey Brooks
12/17/2021, 3:38 PMsuspendCoroutine
route works, but it might be easier and make the intent clearer to use a CompletableDeferred, which would effectively do the same thing