CleanupLoop runs Cleanup periodically until ctx is cancelled.
(done <-chan struct{}, maxAge time.Duration)
| 338 | |
| 339 | // CleanupLoop runs Cleanup periodically until ctx is cancelled. |
| 340 | func (tm *TaskManager) CleanupLoop(done <-chan struct{}, maxAge time.Duration) { |
| 341 | ticker := time.NewTicker(60 * time.Second) |
| 342 | defer ticker.Stop() |
| 343 | for { |
| 344 | select { |
| 345 | case <-ticker.C: |
| 346 | tm.Cleanup(maxAge) |
| 347 | case <-done: |
| 348 | return |
| 349 | } |
| 350 | } |
| 351 | } |