diff --git a/version b/version index cb2b00e4..b5021469 100644 --- a/version +++ b/version @@ -1 +1 @@ -3.0.1 +3.0.2 diff --git a/waitgroup.go b/waitgroup.go index 1daa5c26..e1c0f66d 100644 --- a/waitgroup.go +++ b/waitgroup.go @@ -71,14 +71,17 @@ func (wg *WaitGroup) Until(callBack func(done chan struct{}) bool) { }() } -// closes the done channel passed into `Until()` calls and waits for the `Until()` callBack to return false +// Stop closes the done channel passed into `Until()` calls and waits for +// the `Until()` callBack to return false. func (wg *WaitGroup) Stop() { wg.mutex.Lock() + defer wg.mutex.Unlock() + if wg.done != nil { close(wg.done) } - wg.mutex.Unlock() - wg.Wait() + wg.wg.Wait() + wg.done = nil } // Run a goroutine in a loop continuously, if the callBack returns false the loop is broken