Sfoglia il codice sorgente

check if it is running when calling start(), avoid multiple run() goroutine

chenyunfei 9 anni fa
parent
commit
6f30f62fd6
1 ha cambiato i file con 3 aggiunte e 0 eliminazioni
  1. 3 0
      cron.go

+ 3 - 0
cron.go

@@ -123,6 +123,9 @@ func (c *Cron) Entries() []*Entry {
 
 // Start the cron scheduler in its own go-routine.
 func (c *Cron) Start() {
+	if c.running {
+		return
+	}
 	c.running = true
 	go c.run()
 }