MCPcopy Create free account
hub / github.com/code-scan/Goal / GetTimeoutData

Method GetTimeoutData

Gsensor/ksubdomain/localStruct.go:63–85  ·  view source on GitHub ↗

从链表中取出超时的数据,可选每次取出最多多少数据

(max int)

Source from the content-addressed store, hash-verified

61
62// 从链表中取出超时的数据,可选每次取出最多多少数据
63func (this *LocalStruct) GetTimeoutData(max int) []LocalRetryStruct {
64 this.lock.Lock()
65 defer this.lock.Unlock()
66 currentTime := time.Now().Unix()
67 index := 0
68 var tables []LocalRetryStruct
69 j := 0
70 for i := 0; i < len(this.items); i++ {
71 if currentTime-this.items[i].v.Time < 5 {
72 break
73 }
74 if index > max {
75 break
76 }
77 index++
78 j = i
79 tables = append(tables, LocalRetryStruct{this.items[i].v, this.items[i].index})
80 }
81 if len(tables) > 0 {
82 this.items = append(this.items[j+1:])
83 }
84 return tables
85}

Callers 1

GetResultMethod · 0.80

Calls 1

LockMethod · 0.80

Tested by

no test coverage detected