diff --git a/set_test.go b/set_test.go index b2c3245..56a71ed 100644 --- a/set_test.go +++ b/set_test.go @@ -521,7 +521,6 @@ func testSetConcurrency(t *testing.T, set Set[int]) { for i := range (base + 1) * 100 { set.Add(i) } - finished.Done() }, func(base int) { var x int @@ -531,7 +530,6 @@ func testSetConcurrency(t *testing.T, set Set[int]) { x = set.Cardinality() } _ = x - finished.Done() }, func(base int) { var x bool @@ -541,7 +539,6 @@ func testSetConcurrency(t *testing.T, set Set[int]) { x = set.Contains(i) } _ = x - finished.Done() }, func(base int) { started <- struct{}{} @@ -549,7 +546,6 @@ func testSetConcurrency(t *testing.T, set Set[int]) { for i := range (base + 1) * 100 { set.Remove(i) } - finished.Done() }, func(base int) { other := New[int]() @@ -560,7 +556,6 @@ func testSetConcurrency(t *testing.T, set Set[int]) { <-start AppendSeq(other, set.Iterator) RemoveSeq(set, other.Iterator) - finished.Done() }, func(base int) { var x int @@ -572,14 +567,14 @@ func testSetConcurrency(t *testing.T, set Set[int]) { } } _ = x - finished.Done() }, } count := 20 for i := range count { - finished.Add(len(goroutines)) for j := range len(goroutines) { - go goroutines[j](i) + finished.Go(func() { + goroutines[j](i) + }) } } diff --git a/sync.go b/sync.go index 845210a..105929a 100644 --- a/sync.go +++ b/sync.go @@ -67,7 +67,7 @@ func (s *SyncMap[M]) Pop() (M, bool) { var m M var ok bool - s.m.Range(func(key, _ interface{}) bool { + s.m.Range(func(key, _ any) bool { if _, ok = s.m.LoadAndDelete(key); ok { m = key.(M) ok = true @@ -88,7 +88,7 @@ func (s *SyncMap[M]) Cardinality() int { return 0 } var n int - s.m.Range(func(_, _ interface{}) bool { + s.m.Range(func(_, _ any) bool { n++ return true }) @@ -98,7 +98,7 @@ func (s *SyncMap[M]) Cardinality() int { // Iterator yields all elements in the set. It is safe to call concurrently with other methods, but the order and // behavior is undefined, as per [sync.Map]'s `Range`. func (s *SyncMap[M]) Iterator(yield func(M) bool) { - s.m.Range(func(key, _ interface{}) bool { + s.m.Range(func(key, _ any) bool { return yield(key.(M)) }) }