Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Abdulsametileri/2b2a142f1ff9d85e31b07598ecf6dcf3 to your computer and use it in GitHub Desktop.
Save Abdulsametileri/2b2a142f1ff9d85e31b07598ecf6dcf3 to your computer and use it in GitHub Desktop.
workerpoolpattern-in.go
package processor
import "sync"
type workerPool struct {
limit chan struct{}
wg sync.WaitGroup
}
func (l *workerPool) acquire() {
l.wg.Add(1)
l.limit <- struct{}{}
}
func (l *workerPool) wait() {
l.wg.Wait()
}
func (l *workerPool) release() {
<-l.limit
l.wg.Done()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment