Ulrik Rasmussen
05/31/2021, 4:59 AMc
. The first coroutine calls c.send(i)
followed by `c.receive()`; the second does val i = c.receive()
, then checks if i
is even and only then does c.send(i+1)
. The first coroutine will block forever on`c.receive()` if it sent an odd i
in the beginning. It should be possible to reliably detect this situation under the assumption that no other coroutines know c
, and detecting (asynchronously) that the dispatcher is out of work. Preferably I would like to be able to do this in the first coroutine, i.e. effectively doing c.receiveOrThrowOnDeadlock()
.uli
05/31/2021, 1:48 PMUlrik Rasmussen
05/31/2021, 1:50 PMuli
05/31/2021, 1:53 PMidle
before it is resumed at some later point in time?Ulrik Rasmussen
06/01/2021, 6:11 AMc.send()
from (a) will either (1) cause the continuation of (b) to be dispatched before (a) suspends; or directly continue executing the continuation of (b). In either case, the worker thread is either still active and/or the list of work is non-empty. In the case where (a) calls c.receive()
and suspends, I think the work thread will become idle for the first time because there is no more work to be done. If a coroutine could be activated in that situation, e.g. via a select query, then it could possibly query the state of the channels and conclude that there is a deadlock.kotest
. The problem is that the correct behavior in many test cases will be for a node to simply ignore an incoming invalid message, but in order to end the test case I need to ensure that no further progress will be made. Relying on timeouts makes it impossible to apply randomized testing because the test suite would take days to finish, mostly just by idling.uli
06/01/2021, 6:54 AMUlrik Rasmussen
06/01/2021, 8:49 AM