import "github.com/fufuok/utils/sched"
- type Option
- type Pool
- func New(opts ...Option) *Pool
- func (p *Pool) Add(numTasks int) int
- func (p *Pool) IsRunning() bool
- func (p *Pool) Release()
- func (p *Pool) Run(f ...func())
- func (p *Pool) RunWithArgs(f func(args ...interface{}), args ...interface{})
- func (p *Pool) Running() uint64
- func (p *Pool) Wait()
- func (p *Pool) WaitAndRelease()
Option is a scheduler option.
type Option func(w *Pool)
func Queues(limit int) Option
Queues is buffer capacity of the tasks channel.
func Workers(limit int) Option
Workers is number of workers that can execute tasks concurrently.
Pool is a worker pool.
type Pool struct {
// contains filtered or unexported fields
}
func New(opts ...Option) *Pool
New creates a new task scheduler and returns a pool of workers.
func (p *Pool) Add(numTasks int) int
func (p *Pool) IsRunning() bool
func (p *Pool) Release()
func (p *Pool) Run(f ...func())
Run runs f in the current pool.
func (p *Pool) RunWithArgs(f func(args ...interface{}), args ...interface{})
func (p *Pool) Running() uint64
func (p *Pool) Wait()
func (p *Pool) WaitAndRelease()
Generated by gomarkdoc