MCPcopy Create free account
hub / github.com/bslatkin/effectivepython / simulate_threaded

Function simulate_threaded

example_code/item_072.py:140–154  ·  view source on GitHub ↗
(grid)

Source from the content-addressed store, hash-verified

138 set_cell(y, x, next_state)
139
140def 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
157print("Example 3")

Callers 1

item_072.pyFile · 0.85

Calls 2

LockingGridClass · 0.70
appendMethod · 0.45

Tested by

no test coverage detected