usage is also not going to grow more complex really:
There's a "main goroutine" that loops, in each loop iteration fires off two
separate goroutines, does some stuff on its own, then waits for the 2
routines to finish, then next loop iteration.
The waiting is done with two booleans (say, jobFooDone and jobBarDone) in
the scope of the main goroutine. This may seem archaic but in this really
quite simple scenario I don't see how it could go wrong -- can you?
Each boolean is only ever set to false by the main routine (beginning of
the loop iteration prior to launching the goroutine), and only ever set to
true by the job goroutine (just before it returns -- btw would be great if
we could defer non-func-call statements). Hardly a real pressing "clean &
proper" syncing need here, or is there? (Not talking about communicating
other data between the goroutines right here, just the waiting part that
WaitGroup would also address.)
I can see in waitgroup.go all sorts of atomic operations being done and I
can see how that will be very very handy when the number of goroutines
being launched is dynamic/unknown/greater than 2 or 3. But for my simple
case, would there be any benefit or indeed necessity to switch to WaitGroup
from my two simple boolean vars?
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 firstname.lastname@example.org.
For more options, visit https://groups.google.com/groups/opt_out.