Skip to content

Commit

Permalink
Merge pull request #47 from mailgun/thrawn/develop
Browse files Browse the repository at this point in the history
Stop now correctly clears the done channel after all the work groups stop
  • Loading branch information
thrawn01 authored Aug 22, 2019
2 parents 3fb2ff5 + 25f0568 commit 57ffcf4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.1
3.0.2
9 changes: 6 additions & 3 deletions waitgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 57ffcf4

Please sign in to comment.