新增时间轮定时器

This commit is contained in:
boyce
2020-10-24 16:55:55 +08:00
parent 18281e2b09
commit 2b05358f04
5 changed files with 171 additions and 194 deletions

View File

@@ -138,13 +138,15 @@ func (slf *Service) Run() {
analyzer = nil
}
case t := <- slf.dispatcher.ChanTimer:
if slf.profiler!=nil {
analyzer = slf.profiler.Push(fmt.Sprintf("Timer_%s", t.GetFunctionName()))
}
t.Cb()
if analyzer!=nil {
analyzer.Pop()
analyzer = nil
if t.IsStop() == false {
if slf.profiler != nil {
analyzer = slf.profiler.Push(fmt.Sprintf("Timer_%s", t.AdditionData.(*timer.Timer).GetFunctionName()))
}
t.AdditionData.(*timer.Timer).Cb()
if analyzer != nil {
analyzer.Pop()
analyzer = nil
}
}
}