Created
June 17, 2015 21:08
-
-
Save objarni/68cd2758dc2e2c4769b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MachineRunner(object): | |
"""Simple quantuum programming inspired finite state machine runner""" | |
def add_machine(self, machine): | |
self.signal_queue = Queue.Queue() # good for concurrent/threade op! | |
self.machines.append(machine) | |
def tick(self): | |
while self.signal_queue.has_items(): | |
sig = self.signal_queue.pop() | |
for m in self.machines: | |
m.dispatch(sig) | |
def publish(signal): | |
self.signal_queue.push(signal) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment