MCPcopy
hub / github.com/grafana/tempo / TestStopUnblocksAllWaiters

Function TestStopUnblocksAllWaiters

pkg/flushqueues/exclusivequeues_test.go:216–237  ·  view source on GitHub ↗

TestStopUnblocksAllWaiters verifies that calling Stop on an empty queue unblocks all goroutines waiting in Dequeue, returning zero values.

(t *testing.T)

Source from the content-addressed store, hash-verified

214// TestStopUnblocksAllWaiters verifies that calling Stop on an empty queue
215// unblocks all goroutines waiting in Dequeue, returning zero values.
216func TestStopUnblocksAllWaiters(t *testing.T) {
217 q := New[mockOp](nil)
218 numWorkers := 5
219
220 var allStarted sync.WaitGroup
221 allStarted.Add(numWorkers)
222
223 var workers sync.WaitGroup
224 for i := range numWorkers {
225 workers.Add(1)
226 go func() {
227 defer workers.Done()
228 allStarted.Done()
229 op := q.Dequeue()
230 assert.Equal(t, mockOp{}, op, "worker %d: expected zero value from closed queue", i)
231 }()
232 }
233
234 allStarted.Wait()
235 q.Stop()
236 workers.Wait()
237}

Callers

nothing calls this directly

Calls 6

AddMethod · 0.65
DoneMethod · 0.65
WaitMethod · 0.65
StopMethod · 0.65
DequeueMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected