Skip to content

Commit

Permalink
Merge pull request #1 from kr1sten0/master
Browse files Browse the repository at this point in the history
Renaming and more clear logic
  • Loading branch information
taowen committed Mar 6, 2018
2 parents 28f5fe9 + 94ffc7f commit 797cd41
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions unbounded_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,19 @@ func (executor *UnboundedExecutor) StopAndWaitForever() {
func (executor *UnboundedExecutor) StopAndWait(ctx context.Context) {
executor.cancel()
for {
fiveSeconds := time.NewTimer(time.Millisecond * 100)
oneHundredMilliseconds := time.NewTimer(time.Millisecond * 100)
select {
case <-fiveSeconds.C:
case <-oneHundredMilliseconds.C:
if executor.checkNoActiveGoroutines() {
return
}
case <-ctx.Done():
return
}
if executor.checkGoroutines() {
return
}
}
}

func (executor *UnboundedExecutor) checkGoroutines() bool {
func (executor *UnboundedExecutor) checkNoActiveGoroutines() bool {
executor.activeGoroutinesMutex.Lock()
defer executor.activeGoroutinesMutex.Unlock()
for startFrom, count := range executor.activeGoroutines {
Expand Down

0 comments on commit 797cd41

Please sign in to comment.