ah yes, no, if you see the code in the play link below, it only has three
channels, ops, done and ready. I just figured out that I replaced that
ready by putting the close in the clause that processes incoming ops, and
it's unused as well. I managed to trim it down to just one channel, the ops
oh, I did forget one thing. The race detector does not flag a race in this
code: https://play.golang.org/p/M1uGq1g4vjo (play refuses to run it though)
As I understand it, that's because the add/subtract operations are
happening serially within the main handler goroutine. I suppose if I were
to
I more or less eventually figured that out since it is impossible to query
the number of workers without a race anyway, and then I started toying with
atomic.Value and made that one race as well (obviously the value was copied
by fmt.Println). I guess keeping track of the number of workers is on
Channels use sync primitives under the hood so you are not saving anything by
using multiple channels instead of a single wait group.
> On May 2, 2019, at 5:57 PM, Louki Sumirniy
> wrote:
>
> As I mentioned earlier, I wanted to see if I could implement a waitgroup with
> channels instead of
Ah, so this is what they are for - the same thing implemented with channels
would be a nasty big slice with empty struct quit channels to first tell
the main they are done. wg.Done() and wg.Wait() eliminate the complexity
that a pure channel implementation would require.
With that code I also
You can see it doesn't wait by adding a counter as seen here:
https://play.golang.org/p/-eqKggUEjhQ
On 02/05/2019 21:09, Louki Sumirniy wrote:
I have been spending my time today getting my knowledge of this
subject adequate enough to use channels for a UDP transport with FEC
creating sharded pi
Without the wait group it doesn't wait, so you're not guaranteed for all
/ any of the goroutines to complete.
On 02/05/2019 21:09, Louki Sumirniy wrote:
I have been spending my time today getting my knowledge of this
subject adequate enough to use channels for a UDP transport with FEC
creating