8 ms·
Where is that semaphore struct from? I can't find sync.NewSemaphore in "sync" or "golang.org/x/sync".
by makeworld 6y ago
Where is that semaphore struct from? I can't find sync.NewSemaphore in "sync" or "golang.org/x/sync".
- Thaxll 6y agoThere is a more standard way of doing that with a blocking channel. c := make(chan struct{}, 10) for job := range jobs { c <- struct{}{} go func(){ defer func() { <-c }() }(job) }
- andrenth 6y agoI believe it's meant to be sem := semaphore.NewWeighted(int64(runtime.NumCPU())) from "golang.org/x/sync/semaphore"