4 ms·
> Blocked channel reads and writes are unblocked in FIFO order, not random This should be obvious since the buffer is optional. > but the chan part was a surp
by akira2501 2y ago
> Blocked channel reads and writes are unblocked in FIFO order, not random
This should be obvious since the buffer is optional.
> but the chan part was a surprise to me
With multiple receivers it is effectively random _which_ receiver gets the wakeup.
- Groxx 2y agoYeah, I don't mean buffered data. I mean blocked queueing operations. >With multiple receivers it is effectively random _which_ receiver gets the wakeup. That's why I brought it up: no it isn't. It's ordered. Intentionally. https://github.com/golang/go/issues/11506 https://github.com/golang/go/issues/11506 It's pretty easy to prove to yourself too, it only takes a couple dozen lines to write a test. I'm not confident it's guaranteed in all scenarios (mutexes are not, for example), but I've yet to see it do anything but perfect FIFO when not racing on starting both read and write simultaneously. --- A single select statement with multiple eligible channel operations is random, which is part of why I expected blocked channel operations themselves to be random. But nope.