(grid)
| 138 | set_cell(y, x, next_state) |
| 139 | |
| 140 | def simulate_threaded(grid): |
| 141 | next_grid = LockingGrid(grid.height, grid.width) |
| 142 | |
| 143 | threads = [] |
| 144 | for y in range(grid.height): |
| 145 | for x in range(grid.width): |
| 146 | args = (y, x, grid.get, next_grid.set) |
| 147 | thread = Thread(target=step_cell, args=args) |
| 148 | thread.start() # Fan-out |
| 149 | threads.append(thread) |
| 150 | |
| 151 | for thread in threads: |
| 152 | thread.join() # Fan-in |
| 153 | |
| 154 | return next_grid |
| 155 | |
| 156 | |
| 157 | print("Example 3") |
no test coverage detected