MCPcopy
hub / github.com/panjf2000/ants / binarySearch

Method binarySearch

worker_stack.go:85–95  ·  view source on GitHub ↗
(l, r int, expiryTime int64)

Source from the content-addressed store, hash-verified

83}
84
85func (ws *workerStack) binarySearch(l, r int, expiryTime int64) int {
86 for l <= r {
87 mid := l + ((r - l) >> 1) // avoid overflow when computing mid
88 if expiryTime < ws.items[mid].lastUsedTime() {
89 r = mid - 1
90 } else {
91 l = mid + 1
92 }
93 }
94 return r
95}
96
97func (ws *workerStack) reset() {
98 for i := 0; i < ws.len(); i++ {

Callers 3

refreshMethod · 0.95
TestSearchFunction · 0.45
TestRotatedQueueSearchFunction · 0.45

Calls 1

lastUsedTimeMethod · 0.65

Tested by 2

TestSearchFunction · 0.36
TestRotatedQueueSearchFunction · 0.36