Browse Source

Renaming and more clear logic

kr1sten0 7 years ago
parent
commit
94ffc7f336
1 changed files with 6 additions and 6 deletions
  1. 6 6
      unbounded_executor.go

+ 6 - 6
unbounded_executor.go

@@ -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 {