Don't return OK from status until all parts are ready

This commit is contained in:
Bryan Boreham committed 2017-05-11 14:02:45 +00:00
1 parent 3e0eb4ac1e
commit 7611cd963c
6 files changed
+57 -15

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
package common
import (
"sync"
"sync/atomic"
)
type WaitGroup struct {
wg sync.WaitGroup
count int32
}
// Increase the count of things waiting and return a closure which calls Done
func (w *WaitGroup) Add() func() {
atomic.AddInt32(&w.count, 1)
w.wg.Add(1)
return func() {
w.wg.Done()
atomic.AddInt32(&w.count, -1)
}
}
func (w *WaitGroup) IsDone() bool {
return atomic.LoadInt32(&w.count) == 0
}