MCPcopy
hub / github.com/grafana/tempo / Dequeue

Method Dequeue

pkg/flushqueues/priority_queue.go:111–131  ·  view source on GitHub ↗

Dequeue will return the op with the highest priority; block if queue is empty; returns the zero value of T if queue is closed.

()

Source from the content-addressed store, hash-verified

109// Dequeue will return the op with the highest priority; block if queue is
110// empty; returns the zero value of T if queue is closed.
111func (pq *PriorityQueue[T]) Dequeue() T {
112 pq.lock.Lock()
113 defer pq.lock.Unlock()
114
115 for len(pq.queue) == 0 && !pq.closing && !pq.closed {
116 pq.cond.Wait()
117 }
118
119 if len(pq.queue) == 0 && (pq.closing || pq.closed) {
120 pq.closed = true
121 var zero T
122 return zero
123 }
124
125 op := heap.Pop(&pq.queue).(T)
126 delete(pq.hit, op.Key())
127 if pq.lengthGauge != nil {
128 pq.lengthGauge.Dec()
129 }
130 return op
131}

Callers 12

globalCompleteLoopMethod · 0.45
runFlushLoopMethod · 0.45
TestExclusiveQueuesFunction · 0.45
TestMultipleItemsFunction · 0.45
TestExclusiveQueueLocksFunction · 0.45
waitForDequeueFunction · 0.45
TestConcurrentDequeueFunction · 0.45
TestPriorityQueueBasicFunction · 0.45
TestPriorityQueueWaitFunction · 0.45

Calls 3

WaitMethod · 0.65
KeyMethod · 0.65
PopMethod · 0.45

Tested by 10

TestExclusiveQueuesFunction · 0.36
TestMultipleItemsFunction · 0.36
TestExclusiveQueueLocksFunction · 0.36
waitForDequeueFunction · 0.36
TestConcurrentDequeueFunction · 0.36
TestPriorityQueueBasicFunction · 0.36
TestPriorityQueueWaitFunction · 0.36