mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-10 02:43:37 +02:00
refactor(concurrency): replaced manual WaitGroup management with new wg.Go() and removed redundant code.
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package functional
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/puzpuzpuz/xsync/v4"
|
||||
)
|
||||
|
||||
@@ -44,20 +42,6 @@ func (set Set[T]) RangeAll(f func(T)) {
|
||||
})
|
||||
}
|
||||
|
||||
func (set Set[T]) RangeAllParallel(f func(T)) {
|
||||
var wg sync.WaitGroup
|
||||
|
||||
set.Range(func(k T) bool {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
f(k)
|
||||
wg.Done()
|
||||
}()
|
||||
return true
|
||||
})
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
func (set Set[T]) Size() int {
|
||||
return set.m.Size()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user