func (w *Worker) StopContext(ctx context.Context) {
	stopped := make(chan struct{})
	go func() {
		defer func() {
			w.Latch.Reset()
			close(stopped)
		}()

		w.Latch.WaitStopped()
		if workLeft := len(w.Work); workLeft > 0 {
			for x := 0; x < workLeft; x++ {
				w.Execute(ctx, <-w.Work)
			}
		}
	}()
	select {
	case <-stopped:
		return
	case <-ctx.Done():
		return
	}
}
// StopContext stops the worker in a given cancellation context.
StopContext stops the worker in a given cancellation context.
// StopContext stops the worker in a given cancellation context .
func (w *Worker) StopContext(ctx context.Context) {
	stopped := make(chan struct{})
	go func() {
		defer func() {
			w.Latch.Reset()
			close(stopped)
		}()
		w.Latch.WaitStopped()
		if workLeft := len(w.Work); workLeft > 0 {
			for x := 0; x < workLeft; x++ {
				w.Execute(ctx, <-w.Work)
			}
		}
	}()
	select {
	case <-stopped:
		return
	case <-ctx.Done():
		return
	}
}
func ( w * Worker ) StopContext ( ctx context . Context ) { stopped := make ( chan struct { } ) go func ( ) { defer func ( ) { w . Latch . Reset ( ) close ( stopped ) } ( ) w . Latch . WaitStopped ( ) if workLeft := len ( w . Work ) ; workLeft > 0 { for x := 0 ; x < workLeft ; x ++ { w . Execute ( ctx , <- w . Work ) } } } ( ) select { case <- stopped : return case <- ctx . Done ( ) : return } }
StopContext stops the worker in a given cancellation context.
StopContext stops the worker in a given cancellation context .