Explorar el Código

fix waitgroup bug

dcsunny hace 4 años
padre
commit
7f7ba8aa4b
Se han modificado 1 ficheros con 7 adiciones y 1 borrados
  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()