MCPcopy Index your code
hub / github.com/apache/answer / TestQueue_ConcurrentRegisterHandler

Function TestQueue_ConcurrentRegisterHandler

internal/base/queue/queue_test.go:196–212  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

194}
195
196func TestQueue_ConcurrentRegisterHandler(t *testing.T) {
197 q := New[*testMessage]("test", 10)
198 defer q.Close()
199
200 // Concurrently register handlers - should not race
201 var wg sync.WaitGroup
202 for range 10 {
203 wg.Add(1)
204 go func() {
205 defer wg.Done()
206 q.RegisterHandler(func(ctx context.Context, msg *testMessage) error {
207 return nil
208 })
209 }()
210 }
211 wg.Wait()
212}
213
214// TestQueue_SendCloseRace is a regression test for the race condition between
215// Send and Close. Without proper synchronization, concurrent Send and Close

Callers

nothing calls this directly

Calls 3

CloseMethod · 0.65
AddMethod · 0.65
RegisterHandlerMethod · 0.65

Tested by

no test coverage detected