(pool, grid)
| 136 | from concurrent.futures import ThreadPoolExecutor |
| 137 | |
| 138 | def simulate_pool(pool, grid): |
| 139 | next_grid = LockingGrid(grid.height, grid.width) |
| 140 | |
| 141 | futures = [] |
| 142 | for y in range(grid.height): |
| 143 | for x in range(grid.width): |
| 144 | args = (y, x, grid.get, next_grid.set) |
| 145 | future = pool.submit(step_cell, *args) # Fan-out |
| 146 | futures.append(future) |
| 147 | |
| 148 | for future in futures: |
| 149 | future.result() # Fan-in |
| 150 | |
| 151 | return next_grid |
| 152 | |
| 153 | |
| 154 | print("Example 3") |
no test coverage detected