Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Errors. ErrInvalidNumWorkers = errors.New("number of workers must be positive") )
Functions ¶
This section is empty.
Types ¶
type WorkerPool ¶
type WorkerPool struct {
// contains filtered or unexported fields
}
WorkerPool implements a worker pool for executing the same task over many items in parallel.
func New ¶
func New(workerFunc worker.WorkerFunc, numWorkers int) (*WorkerPool, error)
New returns a new WorkerPool instance that will use the given workerFunc to process input items and will have numWorkers workers.
func (*WorkerPool) GetOutputChannel ¶
func (wp *WorkerPool) GetOutputChannel() (<-chan interface{}, error)
GetOutputChannel returns the channel where the result of processing input items will be sent to. The channel will be internally allocated the first time this is called. This must be called at least once before Start().
func (*WorkerPool) SetInputChannel ¶
func (wp *WorkerPool) SetInputChannel(inputChannel chan interface{}) error
SetInputChannel sets the channel where the Workers will read items from. This must be called before Start().
Click to show internal directories.
Click to hide internal directories.