add comment and adjust log position

This commit is contained in:
Maycon Santos
2024-02-27 18:55:09 +01:00
parent 87d1fc3a2f
commit 19873db1a9

View File

@@ -103,15 +103,16 @@ func (wm *DefaultScheduler) Schedule(in time.Duration, ID string, job func() (ne
ticker.Stop()
return
}
if runIn != in { // do we need to compare it with the original duration?
// we need this comparison to avoid resetting the ticker with the same duration and missing the current elapsesed time
if runIn != in {
ticker.Reset(runIn)
}
case <-cancel:
ticker.Stop()
log.Debugf("stopped scheduled job %s ", ID)
wm.mu.Lock()
defer wm.mu.Unlock()
delete(wm.jobs, ID)
log.Debugf("stopped scheduled job %s ", ID)
return
}
}