Browse Source

Merge pull request #91 from icholy/master

Add blocking Run() method
Rob Figueiredo 8 years ago
parent
commit
caf011d12e
1 changed files with 9 additions and 0 deletions
  1. 9 0
      cron.go

+ 9 - 0
cron.go

@@ -146,6 +146,15 @@ func (c *Cron) Start() {
 	go c.run()
 	go c.run()
 }
 }
 
 
+// Run the cron scheduler, or no-op if already running.
+func (c *Cron) Run() {
+	if c.running {
+		return
+	}
+	c.running = true
+	c.run()
+}
+
 func (c *Cron) runWithRecovery(j Job) {
 func (c *Cron) runWithRecovery(j Job) {
 	defer func() {
 	defer func() {
 		if r := recover(); r != nil {
 		if r := recover(); r != nil {