| 187 | } |
| 188 | |
| 189 | func 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 | |
| 230 | func testSaveToFile() { |
| 231 | flow.New().TextFile( |