threadpool alternatives and similar packages
Based on the "Goroutines" category.
Alternatively, view threadpool alternatives based on common mentions on social networks and blogs.
-
semaphore
Semaphore pattern implementation with timeout of lock/unlock operations based on channel and context. -
neilotoole/errgroup
Drop-in alternative to sync/errgroup, limited to a pool of N worker goroutines. -
Hunch
Hunch provides functions like: All, First, Retry, Waterfall etc., that makes asynchronous flow control more intuitive. -
goccm
Go Concurrency Manager package limits the number of goroutines that allowed to run concurrently. -
conexec
A concurrent toolkit to help execute funcs concurrently in an efficient and safe way.It supports specifying the overall timeout to avoid blocking and uses goroutine pool to improve efficiency. -
go-tools/multithreading
Manage a pool of goroutines using this lightweight library with a simple API. -
queue
Gives you a sync.WaitGroup like queue group accessibility. Helps you to throttle and limit goroutines, wait for the end of the all goroutines and much more. -
hands
A process controller used to control the execution and return strategies of multiple goroutines. -
concurrency-limiter
Concurrency limiter with support for timeouts , dynamic priority and context cancellation of goroutines. -
oversight
Oversight is a complete implementation of the Erlang supervision trees.
Get performance insights in less than 4 minutes
Do you think we are missing an alternative of threadpool or a related project?
Popular Comparisons
README
Golang Threadpool implementation
Scalable threadpool implementation using Go to handle the huge network trafic.
Install
go get github.com/shettyh/threadpool
Usage
Threadpool
- Implement
Runnable
interface for tha task that needs to be executed. For example
type MyTask struct { }
func (t *MyTask) Run(){
// Do your task here
}
- Create instance of
ThreadPool
with number of workers required and the task queue sizepool := threadpool.NewThreadPool(200,1000000)
- Create Task and execute
task:=&MyTask{} err := pool.Execute(task)
- Using
Callable
task ``` type MyTaskCallable struct { }
func (c *MyTaskCallable) Call() interface{} { //Do task return result }
//Execute callable task task := &MyTaskCallable{} future, err := pool.ExecuteFuture(task)
//Check if the task is done isDone := future.IsDone() // true/false
//Get response , blocking call result := future.Get()
- Close the pool
pool.Close()
### Scheduled threadpool
- Create instance of `ScheduledThreadPool` with number of workers required
schedulerPool:= threadpool.NewScheduledThreadPool(10)
- Create Task and schedule
task:=&MyTask{} pool.ScheduleOnce(task, time.Second*20) // Time delay is in seconds only as of now
- Close the pool
pool.Close()