MCPcopy
hub / github.com/kopia/kopia / dequeue

Method dequeue

internal/parallelwork/parallel_work_queue.go:97–118  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

95}
96
97func (v *Queue) dequeue(ctx context.Context) CallbackFunc {
98 v.monitor.L.Lock()
99 defer v.monitor.L.Unlock()
100
101 for v.queueItems.Len() == 0 && v.activeWorkerCount > 0 {
102 // no items in queue, but some workers are active, they may add more.
103 v.monitor.Wait()
104 }
105
106 // no items in queue, no workers are active, no more work.
107 if v.queueItems.Len() == 0 {
108 return nil
109 }
110
111 v.activeWorkerCount++
112 v.maybeReportProgress(ctx)
113
114 front := v.queueItems.Front()
115 v.queueItems.Remove(front)
116
117 return front.Value.(CallbackFunc) //nolint:forcetypeassert
118}
119
120func (v *Queue) completed(ctx context.Context) {
121 v.monitor.L.Lock()

Callers 1

ProcessMethod · 0.95

Calls 6

maybeReportProgressMethod · 0.95
LockMethod · 0.65
UnlockMethod · 0.65
WaitMethod · 0.65
RemoveMethod · 0.65
LenMethod · 0.45

Tested by

no test coverage detected