mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-16 03:31:39 +00:00
Fix receiver in order to be consistent: syncs.WaitGroupChan
Signed-off-by: Dmytro Tananayskiy <dmitriyminer@gmail.com>
This commit is contained in:
parent
3a7402aa2d
commit
c431382720
@ -33,7 +33,7 @@ func NewWaitGroupChan() *WaitGroupChan {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DoneChan returns a channel that's closed on completion.
|
// DoneChan returns a channel that's closed on completion.
|
||||||
func (c *WaitGroupChan) DoneChan() <-chan struct{} { return c.done }
|
func (wg *WaitGroupChan) DoneChan() <-chan struct{} { return wg.done }
|
||||||
|
|
||||||
// Add adds delta, which may be negative, to the WaitGroupChan
|
// Add adds delta, which may be negative, to the WaitGroupChan
|
||||||
// counter. If the counter becomes zero, all goroutines blocked on
|
// counter. If the counter becomes zero, all goroutines blocked on
|
||||||
@ -46,10 +46,10 @@ func (c *WaitGroupChan) DoneChan() <-chan struct{} { return c.done }
|
|||||||
// than zero, may happen at any time. Typically this means the calls
|
// than zero, may happen at any time. Typically this means the calls
|
||||||
// to Add should execute before the statement creating the goroutine
|
// to Add should execute before the statement creating the goroutine
|
||||||
// or other event to be waited for.
|
// or other event to be waited for.
|
||||||
func (c *WaitGroupChan) Add(delta int) {
|
func (wg *WaitGroupChan) Add(delta int) {
|
||||||
n := atomic.AddInt64(&c.n, int64(delta))
|
n := atomic.AddInt64(&wg.n, int64(delta))
|
||||||
if n == 0 {
|
if n == 0 {
|
||||||
close(c.done)
|
close(wg.done)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user