Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/savsgio/workerpool
Lightweight and fast worker pool with generics support.
https://github.com/savsgio/workerpool
go golang tool utils worker-pool
Last synced: 4 months ago
JSON representation
Lightweight and fast worker pool with generics support.
- Host: GitHub
- URL: https://github.com/savsgio/workerpool
- Owner: savsgio
- License: apache-2.0
- Created: 2022-05-30T13:05:10.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-04T11:32:53.000Z (12 months ago)
- Last Synced: 2024-06-19T23:14:47.380Z (8 months ago)
- Topics: go, golang, tool, utils, worker-pool
- Language: Go
- Homepage:
- Size: 18.6 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# workerpool
[](https://github.com/savsgio/workerpool/actions?workflow=test)
[](https://goreportcard.com/report/github.com/savsgio/workerpool)
[](https://pkg.go.dev/github.com/savsgio/workerpool)Lightweight and fast worker pool with generics support.
Go version: >=1.18
Based on: [valyala/fasthttp/workerpool.go](https://github.com/valyala/fasthttp)
## Example:
```go
type Foo struct {
A int
B int
}wg := sync.WaitGroup{}
handler := func(args Foo) {
log.Println(args.A + args.B)
wg.Done()
}wp := New(
Config{
MaxWorkersCount: 100,
MaxIdleWorkerDuration: 5 * time.Second,
},
handler,
)for i := 0; i < 10; i++ {
wg.Add(1)
wp.Exec(Foo{A: i, B: i + 1})
}wg.Wait()
```