On Wed, Nov 30, 2016 at 12:36 PM, Daniel Fanjul <daniel.fanjul.alcu...@gmail.com> wrote: > Yes, I saw your assert and I trust it but I don't see how that answers my > question. > > There are 4 things that we expect to happen in order: > 1) assignment to result, > 2) call to wg.Done(), > 3) call to wg.Wait(), > 4) read of result. > > So there is no race condition if we can prove: > A) that (1) happens before (2), > B) that (2) happens before (3), > C) and that (3) happens before (4). > > I understand that B) is true, because of the WaitGroup spec and because of > your assertion. I don't see how it affects the other two points. > > I fail to prove A). How does the spec ensure that (1) happens before (2)? > The spec would ensure it if both actions accessed the same variable, but > they actually do not. > I would expect the spec to say something like "all statements of the > function/method happens before the call to the deferred functions/methods, > regardless the variables they may access" > > Now I realize that I also fail to prove C). I am probably missing some > obvious detail now. I am sorry if that is the case. > I would expect something like "all statements of the function/method happen > before the read of the variable that holds the value to be returned, > regardless the variables they may access"
Why are A and C not covered by "Within a single goroutine, reads and writes must behave as if they executed in the order specified by the program"? Ian -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.