MCPcopy
hub / github.com/chrislusf/glow / testUnrolledStaticLoop

Function testUnrolledStaticLoop

examples/word_count/word_count.go:189–228  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

187}
188
189func testUnrolledStaticLoop() {
190 ch := make(chan int)
191 f1 := flow.New()
192 left := f1.Channel(ch).Partition(2).Map(func(t int) (int, int) {
193 return t, t * 2
194 })
195
196 for i := 0; i < 7; i++ {
197 left = left.Map(func(x, y int) (int, int) {
198 return x + 1, y + 1
199 })
200 }
201
202 outChannel := make(chan struct {
203 X, Y int
204 })
205
206 left.AddOutput(outChannel)
207
208 flow.Ready()
209
210 var wg sync.WaitGroup
211 goStart(&wg, func() {
212 f1.Run()
213 })
214
215 goStart(&wg, func() {
216 for out := range outChannel {
217 fmt.Printf("%d : %d\n", out.X, out.Y)
218 }
219 })
220
221 limit := 5
222 for i := 0; i < limit; i++ {
223 ch <- i
224 }
225 close(ch)
226
227 wg.Wait()
228}
229
230func testSaveToFile() {
231 flow.New().TextFile(

Callers 1

mainFunction · 0.85

Calls 6

goStartFunction · 0.85
MapMethod · 0.80
PartitionMethod · 0.80
ChannelMethod · 0.80
AddOutputMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected