MCPcopy
hub / github.com/grafana/dskit / newAsyncQueue

Function newAsyncQueue

cache/async_queue.go:18–30  ·  cache/async_queue.go::newAsyncQueue
(length, maxConcurrency int)

Source from the content-addressed store, hash-verified

16}
17
18func newAsyncQueue(length, maxConcurrency int) *asyncQueue {
19 q := &asyncQueue{
20 stopCh: make(chan struct{}),
21 queueCh: make(chan func(), length),
22 }
23 // Start a number of goroutines - processing async operations - equal
24 // to the max concurrency we have.
25 q.workers.Add(maxConcurrency)
26 for i := 0; i < maxConcurrency; i++ {
27 go q.asyncQueueProcessLoop()
28 }
29 return q
30}
31
32// submit adds an operation to the queue or returns an error if the queue is full
33func (q *asyncQueue) submit(op func()) error {

Callers 3

newMemcachedClientFunction · 0.85
TestAsyncQueue_RunFunction · 0.85

Calls 2

asyncQueueProcessLoopMethod · 0.95
AddMethod · 0.65

Tested by 2

TestAsyncQueue_RunFunction · 0.68