Are waiting receives from an unbuffered channel ordered?

Is there any guarantee, that this code won’t crash with error?

I can’t find any proof in the specification of the fact that receives from unbuffered channel are ordered, however it seems to be true. I checkout out chan.go source code and it looks like receives that block are ordered, because they are placed in a linked list recvq and taken from it in FIFO order.

Could someone help me out here?

If there are many “readers” on a channel, it is not deterministic which reader will see the next blob of data.

Similarily, it is not deterministic which “writer” will be allowed to hand over its data to the channel if there are many trying to write to a spilled channel.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.