(grid, in_queue, logic_queue, out_queue)
| 337 | |
| 338 | print("Example 9") |
| 339 | def simulate_phased_pipeline(grid, in_queue, logic_queue, out_queue): |
| 340 | for y in range(grid.height): |
| 341 | for x in range(grid.width): |
| 342 | state = grid.get(y, x) |
| 343 | item = (y, x, state, grid.get) |
| 344 | in_queue.put(item) # Fan-out |
| 345 | |
| 346 | in_queue.join() |
| 347 | logic_queue.join() # Pipeline sequencing |
| 348 | item_count = out_queue.qsize() |
| 349 | |
| 350 | next_grid = LockingGrid(grid.height, grid.width) |
| 351 | for _ in range(item_count): |
| 352 | y, x, next_state = out_queue.get() # Fan-in |
| 353 | if isinstance(next_state, Exception): |
| 354 | raise SimulationError(y, x) from next_state |
| 355 | next_grid.set(y, x, next_state) |
| 356 | |
| 357 | return next_grid |
| 358 | |
| 359 | |
| 360 | print("Example 10") |
no test coverage detected