MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / popOldest

Method popOldest

internal/redisqueue/queue.go:199–224  ·  view source on GitHub ↗
(count int)

Source from the content-addressed store, hash-verified

197}
198
199func (q *queue) popOldest(count int) [][]byte {
200 now := time.Now()
201
202 q.mu.Lock()
203 defer q.mu.Unlock()
204
205 q.pruneLocked(now)
206 available := len(q.items) - q.head
207 if available <= 0 {
208 q.items = nil
209 q.head = 0
210 return nil
211 }
212 if count > available {
213 count = available
214 }
215
216 out := make([][]byte, 0, count)
217 for i := 0; i < count; i++ {
218 item := q.items[q.head+i]
219 out = append(out, item.payload)
220 }
221 q.head += count
222 q.maybeCompactLocked()
223 return out
224}
225
226func (q *queue) pruneLocked(now time.Time) {
227 if q.head >= len(q.items) {

Callers 1

PopOldestFunction · 0.80

Calls 2

pruneLockedMethod · 0.95
maybeCompactLockedMethod · 0.95

Tested by

no test coverage detected