Skip to content

Commit

Permalink
Merge branch 'master' of github.com:tdterry/cron
Browse files Browse the repository at this point in the history
  • Loading branch information
tdterry committed Mar 22, 2016
2 parents 2e45103 + 32d9c27 commit 58773a9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,11 @@ func (c *Cron) run() {
}
}

// Stop the cron scheduler.
// Stop stops the cron scheduler if it is running; otherwise it does nothing.
func (c *Cron) Stop() {
if !c.running {
return
}
c.stop <- struct{}{}
c.running = false
}
Expand Down
7 changes: 7 additions & 0 deletions cron_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,13 @@ func TestLocalTimezone(t *testing.T) {
}
}

// Test that calling stop before start silently returns without
// blocking the stop channel.
func TestStopWithoutStart(t *testing.T) {
cron := New()
cron.Stop()
}

type testJob struct {
wg *sync.WaitGroup
name string
Expand Down

0 comments on commit 58773a9

Please sign in to comment.