MCPcopy Index your code
hub / github.com/docker/docker-agent / TestBuffer_Concurrent

Function TestBuffer_Concurrent

pkg/concurrent/buffer_test.go:73–96  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

71}
72
73func TestBuffer_Concurrent(t *testing.T) {
74 t.Parallel()
75 var b Buffer
76 var wg sync.WaitGroup
77
78 const writers = 100
79 for i := range writers {
80 wg.Go(func() {
81 _, _ = b.Write(fmt.Appendf(nil, "%03d", i))
82 })
83 }
84
85 // Concurrent readers should not race with writers.
86 for range 50 {
87 wg.Go(func() {
88 _ = b.String()
89 _ = b.Len()
90 _ = b.Bytes()
91 })
92 }
93
94 wg.Wait()
95 assert.Equal(t, writers*3, b.Len())
96}

Callers

nothing calls this directly

Calls 5

WriteMethod · 0.95
StringMethod · 0.95
LenMethod · 0.95
BytesMethod · 0.95
WaitMethod · 0.65

Tested by

no test coverage detected