diff --git a/listhead.go b/listhead.go index 65e6b71..b9ec4e6 100644 --- a/listhead.go +++ b/listhead.go @@ -6,10 +6,10 @@ type ListHead struct { data interface{} } -func (this *ListHead) Init() { +func (this *ListHead) Init(data interface{}) { this.next = this this.prev = this - this.data = nil + this.data = data } func (this *ListHead) Del() { @@ -36,12 +36,12 @@ func (this *ListHead) Replace(pnew *ListHead) { pnew.next.prev = pnew pnew.prev = this.prev pnew.prev.next = pnew - pnew.data = this.data } func (this *ListHead) ReplaceInit(pnew *ListHead) { this.Replace(pnew) - this.Init() + this.next = this + this.prev = this } func (this *ListHead) Empty() bool { @@ -50,5 +50,6 @@ func (this *ListHead) Empty() bool { func (this *ListHead) DelInit() { this.Del() - this.Init() + this.next = this + this.prev = this } diff --git a/timer.go b/timer.go index 06fecfd..2efb277 100644 --- a/timer.go +++ b/timer.go @@ -38,7 +38,7 @@ func (this *Timer) Init( cacheTimerNum int32) { initListHeadFunc := func (data interface{}) { head := data.(*ListHead) - head.Init() + head.Init(nil) } initListHeadFunc(&this.freeTimerList) TraverseArray(&this.tv1, initListHeadFunc) @@ -122,7 +122,7 @@ func (this *Timer) Update() { func (this *Timer) NewTimerAttacher() *TimerAttacher { attacher := new(TimerAttacher) attacher.timer = this - attacher.timers.Init() + attacher.timers.Init(nil) return attacher } diff --git a/timerlist.go b/timerlist.go index 51e7599..5d21577 100644 --- a/timerlist.go +++ b/timerlist.go @@ -49,8 +49,8 @@ func (this *TimerList) reset() { } func (this *TimerList) init() { - this.entry.Init() - this.attachEntry.Init() + this.entry.Init(this) + this.attachEntry.Init(this) } func (this *TimerList) SetTimerAfterFunc(timerAfterFunc func(*XParams)) { @@ -58,6 +58,5 @@ func (this *TimerList) SetTimerAfterFunc(timerAfterFunc func(*XParams)) { } func (this *TimerList) Attach(timerAttacher *TimerAttacher) { - this.attachEntry.data = this timerAttacher.timers.AddTail(&this.attachEntry) }