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

Function TestAsyncQueue_Run

cache/async_queue_test.go:12–27  ·  cache/async_queue_test.go::TestAsyncQueue_Run
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestAsyncQueue_Run(t *testing.T) {
13 q := newAsyncQueue(10, 10)
14 defer q.stop()
15
16 var i atomic.Int32
17 _ = q.submit(func() { i.Add(1) })
18 _ = q.submit(func() { i.Add(-1) })
19 _ = q.submit(func() { i.Add(1) })
20 _ = q.submit(func() { i.Add(-1) })
21 _ = q.submit(func() { i.Add(1) })
22
23 // Wait for all operations to finish.
24 time.Sleep(100 * time.Millisecond)
25
26 require.Equal(t, int32(1), i.Load())
27}
28
29func TestAsyncQueue_QueueFullError(t *testing.T) {
30 const queueLength = 10

Callers

nothing calls this directly

Calls 6

newAsyncQueueFunction · 0.85
submitMethod · 0.80
AddMethod · 0.65
SleepMethod · 0.65
stopMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected