package main
import(
"github.com/alserov/wpool"
"fmt"
"time"
)
func main() {
pool := wpool.NewPool(3) // inits new pool with 3 workers
go func() {
time.Sleep(time.Second * 3)
pool.Stop() // stops all workers
}()
for i := 0; i < 10; i++ {
// adds new task to pool
pool.Execute(func() error {
// your function
return nil
})
}
// awaits errors from pool
for err := range pool.AwaitError() {
fmt.Println(err)
}
}
-
Notifications
You must be signed in to change notification settings - Fork 0
alserov/wpool
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Golang worker pool
Topics
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published