This is a golang thread pool implementation.
Usage:
executor, err := NewExecutor(DefaultExecutorParams())
executor.Submit(func() { /*do something*/ })
executor.Stop()
Properties:
- Fix number of workers
- FIFO, jobs are executed in the order of submittion
- If number of jobs in the queue is equal to max queue capacity, new submittion will be rejected.
- Jobs sitting in the queue longer than max queue timeout are dropped. (circuit breaking)
- Executor shutdown gracefully until shutdown timeout
TODO:
- benchmark
- runnable interface
- return values of runnable
- running job cancelation
- job scheduled by priority instead of submittion time
- dynamic number of workers based on work load
- Queuing system
- Pre-execute hook
- Stats store