refactor(concurrency): replaced manual WaitGroup management with new wg.Go() and removed redundant code.

This commit is contained in:
yusing
2025-08-16 23:14:40 +08:00
parent 7a9b8b3fb9
commit 11af9d107a
8 changed files with 35 additions and 59 deletions

View File

@@ -12,14 +12,12 @@ func TestRefCounterAddSub(t *testing.T) {
rc := NewRefCounter() // Count starts at 1
var wg sync.WaitGroup
wg.Add(2)
rc.Add()
for range 2 {
go func() {
defer wg.Done()
wg.Go(func() {
rc.Sub()
}()
})
}
wg.Wait()