Bläddra i källkod

fix waitgroup bug

dcsunny 4 år sedan
förälder
incheckning
7f7ba8aa4b
1 ändrade filer med 7 tillägg och 1 borttagningar
  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()