Original post

I’m using the Goland IDE, it’s got a great visual debugger. I have a few sync.WaitGroup s that I need to determine the state of when execution is paused (see screenshot below), but I can’t glean what this information means from the docs.

wgDone

Can anyone help me decipher the exact meaning of this? I’m assuming that whenever the state1 is [3]uint32{0, 0, 0} then wgDone is not waiting on anything and wgDone.Wait() would immediately resume execution. Other than that, I’m not certain the exact meaning of these uint32 in their positions.

Hi @botsarehots,

I’m not sure and I didn’t check in goland IDE but for me it should be the WaitGroup counter

It’s not really a Goland specific thing. That was just to provide some context.

I need to know how to interpret this array as a WaitGroup counter. Does the supplied array mean that it has a counter of two? A counter of one? It’s not intuitive to me.

I found this in documentation:

// 64-bit value: high 32 bits are counter, low 32 bits are waiter count.
// 64-bit atomic operations require 64-bit alignment, but 32-bit
// compilers do not ensure it. So we allocate 12 bytes and then use
// the aligned 8 bytes in them as state, and the other 4 as storage
// for the sema.
state1 [3]uint32

you can also read in Add method for synchronization
https://golang.org/src/sync/waitgroup.go?h=WaitGroup#L20

hope this will add some help to you

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.