Stop stops the cron scheduler if it is running; otherwise it does nothing. A context is returned so the caller can wait for running jobs to complete.
()
| 321 | // Stop stops the cron scheduler if it is running; otherwise it does nothing. |
| 322 | // A context is returned so the caller can wait for running jobs to complete. |
| 323 | func (c *Cron) Stop() context.Context { |
| 324 | c.runningMu.Lock() |
| 325 | defer c.runningMu.Unlock() |
| 326 | if c.running { |
| 327 | c.stop <- struct{}{} |
| 328 | c.running = false |
| 329 | } |
| 330 | ctx, cancel := context.WithCancel(context.Background()) |
| 331 | go func() { |
| 332 | c.jobWaiter.Wait() |
| 333 | cancel() |
| 334 | }() |
| 335 | return ctx |
| 336 | } |
| 337 | |
| 338 | // entrySnapshot returns a copy of the current cron entry list. |
| 339 | func (c *Cron) entrySnapshot() []Entry { |
no outgoing calls