* Joubin Houshyar <jhoush...@gmail.com> [160822 12:36]:
> On Monday, August 22, 2016 at 10:27:06 AM UTC-4, Marvin Renich wrote:
> > * Joubin Houshyar <jhou...@gmail.com <javascript:>> [160822 09:47]: 
> > > 
> > > Your firend is correct that using a WaitGroup here does not in anyway 
> > > address concurrent access to the heap variable 'result'. 

I obviously (still) misunderstand what you are saying here.  Taking the
OP's question at face value, and assuming that important details were
not left out, the OP's friend is simply wrong, and using the WaitGroup
does, indeed, address the concurrent access to the variable 'result'.

> > In the original code given by the OP, there is only one assignment to 
> > result (in the goroutine), and only one read from result (in the return 
> > statement).  The WaitGroup properly orders these statements, so there is 
> > no race condition. 
> 
> Didn't say there was.
> 
> > If the OP's friend was trying to say that there easily could be a race 
> > condition if the code was modified to access result in process() after 
> > the go stmt but before the Wait, he would be correct, or if the OP did 
> > not post the full code that his friend was talking about, there might 
> > also be a race condition in the code his friend saw. 
> 
> That's my assumption here. 
> 
> > But the WaitGroup in the originally posted code does properly order the 
> > two accesses to result. 
> 
> Didn't say it didn't. 

...Marvin

-- 
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.

Reply via email to