Skip to content

Commit

Permalink
leftovers round #2
Browse files Browse the repository at this point in the history
  • Loading branch information
amirylm committed Sep 8, 2023
1 parent 84ec47d commit c97755a
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions core/utils/thread_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ type threadControl struct {
}

func (tc *threadControl) Go(fn func(context.Context)) {
tc.add()
tc.threadsWG.Add(1)
go func() {
defer tc.done()
defer tc.threadsWG.Done()
ctx, cancel := tc.stop.NewCtx()
defer cancel()
fn(ctx)
Expand All @@ -46,13 +46,3 @@ func (tc *threadControl) Close() {
close(tc.stop)
tc.threadsWG.Wait()
}

func (tc *threadControl) add() {
tc.running.Add(1)
tc.threadsWG.Add(1)
}

func (tc *threadControl) done() {
tc.running.Add(-1)
tc.threadsWG.Done()
}

0 comments on commit c97755a

Please sign in to comment.