瀏覽代碼

Merge pull request #1 from kr1sten0/master

Renaming and more clear logic
Tao Wen 7 年之前
父節點
當前提交
797cd41b5c
共有 1 個文件被更改,包括 6 次插入6 次删除
  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 {