* Konstantin Shaposhnikov [160820 06:34]:
> The code might be race free for the current Go implementation but I don't
> think this behaviour is documented.
>
> https://golang.org/ref/mem doesn't mention sync.WaitGroup at all. So
> wg.Done() doesn't necessarily happen
The code might be race free for the current Go implementation but I don't
think this behaviour is documented.
https://golang.org/ref/mem doesn't mention sync.WaitGroup at all. So
wg.Done() doesn't necessarily happen before wg.Wait() returns and the
effect of writing to "result" could be not
I haven't run the code under the race detector (hint, do this and you'll have
the official answer) but I don't believe wg.Wait creates a happens before event
that ensures the assignment to result will be visible to other goroutine.
--
You received this message because you are subscribed to
On Sat, Aug 20, 2016 at 8:29 AM Yulrizka wrote:
> He argues that this is heap race condition.
I don't know what is a heap race condition but the code is race free.
--
-j
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
Dear gophers
I have discussion with my colleague about this code
func process() *foo {
var result *foo
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
result = {1}
}()
wg.Wait()
return result
}
He argues that this is heap race