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

Function ExampleSharedBuffer

shared_buffer_test.go:104–127  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

102}
103
104func ExampleSharedBuffer() {
105 // never more than 3 elements in the pipeline at once
106 buf := NewSharedBuffer(3)
107
108 ch1 := buf.NewChannel()
109 ch2 := buf.NewChannel()
110
111 // or, instead of a straight pipe, implement your pipeline step
112 Pipe(ch1, ch2)
113
114 // inputs
115 go func() {
116 for i := 0; i < 20; i++ {
117 ch1.In() <- i
118 }
119 ch1.Close()
120 }()
121
122 for _ = range ch2.Out() {
123 // outputs
124 }
125
126 buf.Close()
127}

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…