txaty / gool

Generic goroutine pool: Submit, Map, Async.

Home Page:https://pkg.go.dev/github.com/txaty/gool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gool

Go Reference Go Report Card codecov

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.

About

Generic goroutine pool: Submit, Map, Async.

https://pkg.go.dev/github.com/txaty/gool

License:MIT License


Languages

Language:Go 90.9%Language:Makefile 9.1%