From 6fd253d4550d483dc8239d6332a91ffd7caa1381 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 8 Sep 2020 18:26:02 +0800 Subject: [PATCH] 1 --- timer.go | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/timer.go b/timer.go index aea3566..ecfcd17 100644 --- a/timer.go +++ b/timer.go @@ -119,6 +119,13 @@ func (this *Timer) Update() { this.runningTimer = nil } +func (this *Timer) NewTimerAttacher() *TimerAttacher { + attacher := new(TimerAttacher) + attacher.timer = this + attacher.timers.Init() + return attacher +} + func (this *Timer) AddDeadLineTimer( milli_seconds int32, init_func func (params* XParams), @@ -226,10 +233,6 @@ func (this *Timer) DeleteTimer(timerList *TimerList) { this.addToFreeList(timerList) } -func (this *Timer) GetTimerByAtttach(attachEntry *ListHead) *TimerList { - return nil -} - func (this *Timer) GetRemainTime(timerList *TimerList) int64 { if timerList == nil { return 0 @@ -246,8 +249,15 @@ func (this *Timer) GetRunningTimer() *TimerList { return this.runningTimer } -func (this *Timer) GetIdleMilliSeconds() int64 { - return 0 +func (this *Timer) GetIdleTime() int64 { + var idleTime int64 = 1 + for i := (this.timerTick & TVR_MASK); i < TVR_SIZE; i++ { + if !this.tv1[i].Empty() { + break + } + idleTime++ + } + return idleTime } func (this *Timer) detachTimer(timerList *TimerList) {