Joris PZ
12/11/2019, 6:50 PMmarstran
12/11/2019, 7:26 PMchannel.receiveOrNull() ?: return , which at least avoids the exception.todd.ginsberg
12/11/2019, 8:20 PMwhile(!stdout.isClosedForReceive).Joris PZ
12/11/2019, 8:33 PMreceiveOrNull seems to be what I need, thanks! I used while(!isClosedForReceive) before but that doesn't help in the case when my listener is suspended on a receive() call when the computer closes the Channel.Kroppeb
12/11/2019, 8:43 PMhalted field in my while loop. I have no idea why it works as my input channel has unlimited size.
Does the thread always switch coroutine if there is a coroutine waiting for an element to appear in a channel?
I should probably make a more robust system anyway.Joris PZ
12/11/2019, 9:11 PMreceive on a Channel with an empty buffer (or no buffer at all), and it won't continue until some other process calls send . Likewise, calling send on a Channel whose buffer is either full or absent suspends the calling coroutine until some other coroutine calls receive . In that sense, Channels are as much a synchronization primitive as they are a messaging solution.todd.ginsberg
12/11/2019, 9:20 PMKroppeb
12/11/2019, 9:40 PMyield() in my isHalted().