Vlad
02/28/2020, 10:49 AMdelay(Long.MAX_VALUE)
or
Mutex(true).run { lock() }
or something else?diesieben07
02/28/2020, 10:54 AMsuspendCoroutineUninterceptedOrReturn { COROUTINE_SUSPENDED }
But if you plan to ever resume the coroutine, you need to use suspendCoroutineOrReturn instead, otherwise the interceptor (dispatcher) is lost.tseisel
02/28/2020, 12:04 PMdelay(Long.Max_VALUE) is fine.
You can also try suspendCancellableCoroutine<Nothing> {}streetsofboston
02/28/2020, 12:19 PMdelay(Long.MAX_VALUE) may raise issues when unit-testing your Coroutines code. The max-value of the long may cause an overflow when calling advanceTimeBy on your test-coroutine-dispatcher, making the delay an 'negative' value. Using suspendCancellableCoroutine does not have that problemlouiscad
02/28/2020, 12:20 PMawaitCancellation() function that returns Nothing and is using suspendCancellableCoroutine<Nothing> { }elizarov
02/28/2020, 2:46 PMawaitCancellation name. Maybe worth adding to the library.louiscad
02/28/2020, 2:47 PMelizarov
02/28/2020, 2:48 PMelizarov
02/28/2020, 2:50 PMdealy(Long.MAX_VALUE) also works great, BTW, but it does not capture the intent as well as awaitCancellationZach Klippenstein (he/him) [MOD]
02/28/2020, 8:36 PMawaitCancellation was added as a general function, it wouldn’t need to be defined specially for channelFlow anymore, right?louiscad
02/28/2020, 8:43 PMawaitClose (not awaitCancellation) function from ProducerScope. awaitCancellation would be able to replace the no argument version, and would be usable in conjunction with a `try`/`finally` pair, but it would not be the same as the awaitClose { ... } overload taking a lambda.
Do you think awaitCancellation should also have an overload accepting a lambda executed on cancellation?louiscad
03/02/2020, 11:12 AM