MCPcopy Index your code
hub / github.com/coder/coder / Pop

Method Pop

cli/cliutil/queue.go:73–85  ·  view source on GitHub ↗

Pop removes and returns the first item from the queue, waiting until there is something to pop if necessary. If closed, returns false.

()

Source from the content-addressed store, hash-verified

71// Pop removes and returns the first item from the queue, waiting until there is
72// something to pop if necessary. If closed, returns false.
73func (q *Queue[T]) Pop() (T, bool) {
74 var head T
75 q.mu.Lock()
76 defer q.mu.Unlock()
77 for len(q.items) == 0 && !q.closed {
78 q.cond.Wait()
79 }
80 if q.closed {
81 return head, false
82 }
83 head, q.items = q.items[0], q.items[1:]
84 return head, true
85}
86
87func (q *Queue[T]) Len() int {
88 q.mu.Lock()

Callers 2

startReporterMethod · 0.45
TestQueueFunction · 0.45

Calls 3

WaitMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45

Tested by 1

TestQueueFunction · 0.36