Skip to content

Commit df306b0

Browse files
committed
Add blocking Run() method
1 parent 9585fd5 commit df306b0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cron.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,15 @@ func (c *Cron) Start() {
146146
go c.run()
147147
}
148148

149+
// Run the cron scheduler, or no-op if already running.
150+
func (c *Cron) Run() {
151+
if c.running {
152+
return
153+
}
154+
c.running = true
155+
c.run()
156+
}
157+
149158
func (c *Cron) runWithRecovery(j Job) {
150159
defer func() {
151160
if r := recover(); r != nil {

0 commit comments

Comments
 (0)