fix: send on closed channel

This commit is contained in:
Noah Hsu
2022-09-14 15:13:02 +08:00
parent 08a001fbd1
commit 9e5ef974a7
3 changed files with 15 additions and 15 deletions

View File

@ -30,6 +30,10 @@ func (c *Cron) Do(f func()) {
}
func (c *Cron) Stop() {
c.ch <- struct{}{}
close(c.ch)
select {
case _, _ = <-c.ch:
default:
c.ch <- struct{}{}
close(c.ch)
}
}