Browse Source

fix waitgroup bug

dcsunny 4 năm trước cách đây
mục cha
commit
7f7ba8aa4b
1 tập tin đã thay đổi với 7 bổ sung1 xóa
  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()