Skip to content

Instantly share code, notes, and snippets.

@objarni
Created June 17, 2015 21:08
Show Gist options
  • Save objarni/68cd2758dc2e2c4769b1 to your computer and use it in GitHub Desktop.
Save objarni/68cd2758dc2e2c4769b1 to your computer and use it in GitHub Desktop.
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