FAQ

On Wednesday, March 6, 2013 6:15:10 PM UTC-6, Steven Blenkinsop wrote:
On Wednesday, 6 March 2013, Kyle Lemons wrote:

I found the discussion, it was on golang-dev *sigh*

https://groups.google.com/d/msg/golang-dev/ShqsqvCzkWg/Kg30VPN4QmUJ

If you want your brain to melt a little, read the whole thread from top
to bottom. :)
That conversation didn't so much melt my brain as break my heart :(.

The required rule is basically that, given a channel of buffer capacity N
= 0, the (M-N)th receive happens before the Mth send completes for all M >
N. This rule is already true for N == 0, but not otherwise.

The thing is, this ordering is required in order for "send on a buffered
channel will block until there is room in the buffer" to have any meaning.
If the Mth send can happen before the (M-N)th receive, then the buffer
size is greater than its capacity. Which means you have to assume that
buffer capacity is meaningless in order to be able to do the reordering
Dmitry does in that thread :\. It's not as surprising that buffer
capacity ends up being irrelevant later on in his analysis when you realize
that he implicitly made this assumption up front.
This is only relevant in the case of receiver and sender in the same
goroutine though, correct?
To overcome this you just need to be passing some kind of token around,
instead of just waiting for the operations to complete.
Or I am missing something ;)

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

People

Translate

site design / logo © 2021 Grokbase