Index | Files

package chanworker

import ""


Package Files


func NewWorker Uses

func NewWorker(nWorkers int, fn func(el interface{}, ok bool)) chan<- interface{}

NewWorker starts nWorkers goroutines running fn on incoming items sent on the returned channel. fn may block; writes to the channel will buffer. If nWorkers is negative, a new goroutine running fn is called for each item sent on the returned channel. When the returned channel is closed, fn is called with (nil, false) after all other calls to fn have completed. If nWorkers is zero, NewWorker will panic.

Package chanworker imports 2 packages (graph) and is imported by 2 packages. Updated 2018-01-20. Refresh now. Tools for package owners.