MCPcopy Create free account
hub / github.com/eapache/channels / TestSharedBufferConcurrent

Function TestSharedBufferConcurrent

shared_buffer_test.go:75–102  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

73}
74
75func TestSharedBufferConcurrent(t *testing.T) {
76 const threads = 10
77 const iters = 200
78
79 buf := NewSharedBuffer(3)
80 done := make(chan bool)
81
82 for i := 0; i < threads; i++ {
83 go func() {
84 ch := buf.NewChannel()
85 for i := 0; i < iters; i++ {
86 ch.In() <- i
87 val := <-ch.Out()
88 if val.(int) != i {
89 t.Error("Mismatched value out of channel")
90 }
91 }
92 ch.Close()
93 done <- true
94 }()
95 }
96
97 for i := 0; i < threads; i++ {
98 <-done
99 }
100 close(done)
101 buf.Close()
102}
103
104func ExampleSharedBuffer() {
105 // never more than 3 elements in the pipeline at once

Callers

nothing calls this directly

Calls 6

NewChannelMethod · 0.95
CloseMethod · 0.95
NewSharedBufferFunction · 0.85
InMethod · 0.65
OutMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…