func (w *Worker) Dispatch() {
	w.Latch.Started()
	defer w.Latch.Stopped()

	var workItem interface{}
	var stopping <-chan struct{}
	for {
		stopping = w.Latch.NotifyStopping()
		select {
		case <-stopping:
			return
		case <-w.Background().Done():
			return
		default:
		}

		// block on work or stopping
		select {
		case workItem = <-w.Work:
			w.Execute(w.Background(), workItem)
		case <-stopping:
			return
		case <-w.Background().Done():
			return
		}
	}
}
// Dispatch starts the listen loop for work.
Dispatch starts the listen loop for work.
// Dispatch starts the listen loop for work .
func (w *Worker) Dispatch() {
	w.Latch.Started()
	defer w.Latch.Stopped()
	var workItem interface{}
	var stopping <-chan struct{}
	for {
		stopping = w.Latch.NotifyStopping()
		select {
		case <-stopping:
			return
		case <-w.Background().Done():
			return
		default:
		}
		select {
		case workItem = <-w.Work:
			w.Execute(w.Background(), workItem)
		case <-stopping:
			return
		case <-w.Background().Done():
			return
		}
	}
}
func ( w * Worker ) Dispatch ( ) { w . Latch . Started ( ) defer w . Latch . Stopped ( ) var workItem interface { } var stopping <- chan struct { } for { stopping = w . Latch . NotifyStopping ( ) select { case <- stopping : return case <- w . Background ( ) . Done ( ) : return default : } select { case workItem = <- w . Work : w . Execute ( w . Background ( ) , workItem ) case <- stopping : return case <- w . Background ( ) . Done ( ) : return } } }
Dispatch starts the listen loop for work.
Dispatch starts the listen loop for work .
// block on work or stopping