SharedBuffer implements the Buffer interface, and permits multiple SimpleChannel instances to "share" a single buffer. Each channel spawned by NewChannel has its own internal queue (so values flowing through do not get mixed up with other channels) but the total number of elements buffered by all sp
| 34 | //parallelism with goroutines, limiting the total number of elements in the pipeline without limiting the number of elements |
| 35 | //at any particular step. |
| 36 | type SharedBuffer struct { |
| 37 | cases []reflect.SelectCase // 2n+1 of these; [0] is for control, [1,3,5...] for recv, [2,4,6...] for send |
| 38 | chans []*sharedBufferChannel // n of these |
| 39 | count int |
| 40 | size BufferCap |
| 41 | in chan *sharedBufferChannel |
| 42 | } |
| 43 | |
| 44 | func NewSharedBuffer(size BufferCap) *SharedBuffer { |
| 45 | if size < 0 && size != Infinity { |
nothing calls this directly
no outgoing calls
no test coverage detected