Good talk. I wonder how the suspended send function waits until the Queue has more capacity to send. Or in other words how the send coroutine is informed that the Queue has capacity available.
It is usual and dangerous in Java to synchronize on a queue monitor and wait for its size to change. Then whatever consuming thread that acquires the monitor will consume some items release the monitor and notify other waiters.
I guess that in coroutines, above mechanics is not used, it probably works by re-scheduling another
suspend send
coroutine in the executor. Maybe not, maybe it spins lock on the Queue capacity.
The same for the counterpart
suspend consumer
Does anyone can explain what happens internally?