Start launches the background loop. It blocks until ctx is cancelled, then closes w.done.
(ctx context.Context)
| 129 | // Start launches the background loop. It blocks until ctx is |
| 130 | // cancelled, then closes w.done. |
| 131 | func (w *Worker) Start(ctx context.Context) { |
| 132 | defer close(w.done) |
| 133 | |
| 134 | ticker := w.clock.NewTicker(w.interval, "gitsync", "worker") |
| 135 | defer ticker.Stop() |
| 136 | |
| 137 | for { |
| 138 | select { |
| 139 | case <-ctx.Done(): |
| 140 | return |
| 141 | case <-ticker.C: |
| 142 | w.tick(ctx) |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | // Done returns a channel that is closed when the worker exits. |
| 148 | func (w *Worker) Done() <-chan struct{} { |