MCPcopy Create free account
hub / github.com/cortexproject/cortex / Enqueue

Method Enqueue

pkg/util/priority_queue.go:85–98  ·  view source on GitHub ↗

Enqueue adds an operation to the queue in priority order.

(op PriorityOp)

Source from the content-addressed store, hash-verified

83
84// Enqueue adds an operation to the queue in priority order.
85func (pq *PriorityQueue) Enqueue(op PriorityOp) {
86 pq.lock.Lock()
87 defer pq.lock.Unlock()
88
89 if pq.closing || pq.closed {
90 panic("enqueue on closed queue")
91 }
92
93 heap.Push(&pq.queue, op)
94 pq.cond.Broadcast()
95 if pq.lengthGauge != nil {
96 pq.lengthGauge.Inc()
97 }
98}
99
100// Dequeue will remove and return the op with the highest priority; block if queue is
101// empty; returns nil if queue is closed.

Callers 5

TestPriorityQueueBasicFunction · 0.95
TestPriorityQueueCloseFunction · 0.95
enqueueRequestMethod · 0.80

Calls 3

PushMethod · 0.65
BroadcastMethod · 0.45
IncMethod · 0.45

Tested by 4

TestPriorityQueueBasicFunction · 0.76
TestPriorityQueueCloseFunction · 0.76