https://github.com/txaty/gool
Generic goroutine pool: Submit, Map, Async.
https://github.com/txaty/gool
concurrency go golang goroutine goroutine-pool parallel worker-pool
Last synced: about 2 months ago
JSON representation
Generic goroutine pool: Submit, Map, Async.
- Host: GitHub
- URL: https://github.com/txaty/gool
- Owner: txaty
- License: mit
- Created: 2022-08-19T16:33:12.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-21T15:03:08.000Z (over 2 years ago)
- Last Synced: 2025-10-30T18:50:06.154Z (4 months ago)
- Topics: concurrency, go, golang, goroutine, goroutine-pool, parallel, worker-pool
- Language: Go
- Homepage: https://pkg.go.dev/github.com/txaty/gool
- Size: 22.5 KB
- Stars: 72
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Gool
[](https://pkg.go.dev/github.com/txaty/gool)
[](https://goreportcard.com/report/github.com/txaty/gool)
[](https://codecov.io/gh/txaty/gool)
A generic goroutine pool just like Python ThreadPoolExecutor.
Gool provides the following methods:
- ```Submit```: Submit a task and return the result (if any).
- ```AsyncSubmit```: Submit a task and return a future of the result (if any), the future is actually the result
channel.
- ```Map```: Submit a bundle of tasks and return the results in order (if any).
- ```AsyncMap```: Submit a bundle of tasks and return the futures of the results (if any), the futures are the result
channels.
To use Gool, you need to define:
- Handler function: ```handler func(A) R```, and
- Argument: ```arg A```
With types ```A``` and ```R``` being arbitrary types.
You can also specify the number of workers ```numWorkers``` and the task queue size ```cap``` when creating a new pool.