瀏覽代碼

fix waitgroup bug

dcsunny 4 年之前
父節點
當前提交
7f7ba8aa4b
共有 1 個文件被更改,包括 7 次插入1 次删除
  1. 7 1
      common/global_wait_group.go

+ 7 - 1
common/global_wait_group.go

@@ -75,8 +75,14 @@ func NewGlobalWaitGroup(ctx context.Context) *globalWaitGroup {
 }
 
 func (this *globalWaitGroup) SetContext(ctx context.Context) {
-	this.ctx = ctx
+	this.ctx, _ = context.WithCancel(ctx)
 }
+
+func (this *globalWaitGroup) Stop() {
+	this.isStop = true
+	this.Wait()
+}
+
 func (this *globalWaitGroup) Wait() {
 	go func() {
 		this.wait()