|
@@ -5,10 +5,10 @@ import (
|
|
|
)
|
|
|
|
|
|
type Worker struct {
|
|
|
- ctx context.Context
|
|
|
- cancel context.CancelFunc
|
|
|
- chDone chan bool
|
|
|
- stop bool
|
|
|
+ ctx context.Context
|
|
|
+ cancel context.CancelFunc
|
|
|
+ chDone chan bool
|
|
|
+ stopped bool
|
|
|
}
|
|
|
|
|
|
type Callback func(ctx context.Context, w *Worker)
|
|
@@ -36,11 +36,11 @@ func (this *Worker) doit(f func(ctx context.Context, w *Worker)) *Worker {
|
|
|
}
|
|
|
|
|
|
func (this *Worker) Shutdown(ctx context.Context) error {
|
|
|
- if this.stop {
|
|
|
+ if this.stopped {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
- this.stop = true
|
|
|
+ this.stopped = true
|
|
|
|
|
|
ctxb := ctx
|
|
|
if ctxb == nil {
|