优化定时器

This commit is contained in:
boyce
2020-12-11 17:58:43 +08:00
parent e2a156473b
commit ddef1e7165
2 changed files with 7 additions and 7 deletions

View File

@@ -178,7 +178,7 @@ func (m *Module) AfterFunc(d time.Duration, cb func()) *timer.Timer {
return m.dispatcher.AfterFunc(d,cb,m.OnCloseTimer,m.OnAddTimer)
}
func (m *Module) CronFunc(cronExpr *timer.CronExpr, cb func()) *timer.Cron {
func (m *Module) CronFunc(cronExpr *timer.CronExpr, cb func(*timer.Cron)) *timer.Cron {
if m.mapActiveTimer == nil {
m.mapActiveTimer =map[*timewheel.Timer]interface{}{}
}
@@ -186,7 +186,7 @@ func (m *Module) CronFunc(cronExpr *timer.CronExpr, cb func()) *timer.Cron {
return m.dispatcher.CronFunc(cronExpr,cb,m.OnCloseTimer,m.OnAddTimer)
}
func (m *Module) NewTicker(d time.Duration, cb func()) *timer.Ticker {
func (m *Module) NewTicker(d time.Duration, cb func(*timer.Ticker)) *timer.Ticker {
if m.mapActiveTimer == nil {
m.mapActiveTimer =map[*timewheel.Timer]interface{}{}
}