Merge pull request #11 from attestantio/remove-lock

Remove unused lock.
This commit is contained in:
Gary Rowe 2020-12-31 10:09:14 +00:00 committed by GitHub
commit 648e506413
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 8 deletions

View File

@ -64,8 +64,6 @@ func New(ctx context.Context, params ...Parameter) (*Service, error) {
}
// ScheduleJob schedules a one-off job for a given time.
// This function returns two cancel funcs. If the first is triggered the job will not run. If the second is triggered the job
// runs immediately.
// Note that if the parent context is cancelled the job wil not run.
func (s *Service) ScheduleJob(ctx context.Context, name string, runtime time.Time, jobFunc scheduler.JobFunc, data interface{}) error {
if name == "" {
@ -101,9 +99,7 @@ func (s *Service) ScheduleJob(ctx context.Context, name string, runtime time.Tim
s.monitor.JobCancelled()
case <-cancelCh:
log.Trace().Str("job", name).Str("scheduled", fmt.Sprintf("%v", runtime)).Msg("Cancel triggered; job not running")
s.mutex.Lock()
// The job will have already been removed.
s.mutex.Unlock()
// The job will have been removed by the function that sent the cancel.
s.monitor.JobCancelled()
case <-runCh:
s.mutex.Lock()
@ -197,9 +193,7 @@ func (s *Service) SchedulePeriodicJob(ctx context.Context, name string, runtimeF
return
case <-cancelCh:
log.Trace().Str("job", name).Str("scheduled", fmt.Sprintf("%v", runtime)).Msg("Cancel triggered; job not running")
s.mutex.Lock()
// The job will have already been removed.
s.mutex.Unlock()
// The job will have been removed by the function that sent the cancel.
s.monitor.JobCancelled()
return
case <-runCh: