package q5 type TimerAttacher struct { timer *Timer timers ListHead } func (this *TimerAttacher) ClearTimers() { var workList ListHead this.timers.ReplaceInit(&workList) for !workList.Empty() { timerList := workList.FirstEntry().(*TimerList) this.timer.DeleteTimer(timerList) } } type TimerList struct { entry ListHead attachEntry ListHead timerType int8 milliSeconds int32 expires int64 timerFunc func (params *XParams) timerAfterFunc func (params *XParams) params XParams } func (this *TimerList) initTimerList( timer interface{}, timerType int8, millSeconds int32, timerFunc func (params *XParams)) { this.timerType = timerType this.milliSeconds = millSeconds this.timerFunc = timerFunc } func (this *TimerList) reset() { if !this.entry.Empty() { this.entry.DelInit() } if !this.attachEntry.Empty() { this.attachEntry.DelInit() } this.timerFunc = nil this.timerAfterFunc = nil this.params.Reset() } func (this *TimerList) init() { this.entry.Init(this) this.attachEntry.Init(this) } func (this *TimerList) SetTimerAfterFunc(timerAfterFunc func(*XParams)) { this.timerAfterFunc = timerAfterFunc } func (this *TimerList) Attach(timerAttacher *TimerAttacher) { timerAttacher.timers.AddTail(&this.attachEntry) }