Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher struct contains the necessary data to spawn the workers and start each worker, it contains a worker pool channel of fixed size ie buffered
func NewDispatcher ¶
func NewDispatcher(maxWorkers int) *Dispatcher
NewDispatcher method will return a dispatcher object
func (*Dispatcher) Run ¶
func (d *Dispatcher) Run(jobPool chan Job)
Run method will start the workers with the given jobPool which will be a buffered channel
func (*Dispatcher) Stop ¶
func (d *Dispatcher) Stop()
Stop method will stop the dispatcher and its workers
type Task ¶
type Task struct {
// contains filtered or unexported fields
}
Task struct is just a wrapper for sync.WaitGroup
type TaskQueue ¶
type TaskQueue struct {
// contains filtered or unexported fields
}
TaskQueue should be used when you want to limit the number of tasks you want to process in background
func NewTaskQueue ¶
NewTaskQueue will create a new taskqueue of buffered job channel
func (*TaskQueue) AddJob ¶
AddJob method will add the job to the queue, this method is blocking since if the queue is full then it will wait till a job is finished