Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type WorkersPool ¶
type WorkersPool struct {
// contains filtered or unexported fields
}
WorkersPool provides a simple synchronization between workers doing some work. First add jobs by using AddWork(), then add a worker function using `SetWorker`. Finally, start as many workers as you want using `Start`.
func (*WorkersPool) AddWork ¶
func (w *WorkersPool) AddWork(job interface{})
func (*WorkersPool) SetWorker ¶
func (w *WorkersPool) SetWorker(workerFunc func(int, interface{}))
SetWorker defines function that will be run by workers. workerFunc accepts two parameters:
- first provides ID of the worker [0, workers-1],
- seconds provides data that worker should work on.
func (*WorkersPool) Start ¶
func (w *WorkersPool) Start(workers int)
Start starts worker to execute workerFunc
func (*WorkersPool) WorkSize ¶
func (w *WorkersPool) WorkSize() int
Click to show internal directories.
Click to hide internal directories.