lib/metacosm/simulation.rb in metacosm-0.2.1 vs lib/metacosm/simulation.rb in metacosm-0.2.2
- old
+ new
@@ -4,11 +4,10 @@
def watch(model)
Frappuccino::Stream.new(model).on_value(&method(:receive))
end
def fire(command)
- # p [ :firing, command: command ]
command_queue.push(command)
end
def command_queue
@command_queue ||= Queue.new
@@ -30,17 +29,16 @@
def halt!
@conductor_thread.terminate
end
def mutex
- @mutex = Mutex.new
+ @mutex = Mutex.new
end
def apply(command)
- #mutex.synchronize do
- # p [ :applying, command: command ]
- handler_for(command).handle(command.attrs)
- #end
+ mutex.synchronize do
+ handler_for(command).handle(command.attrs)
+ end
end
def receive(event, record: true)
events.push(event) if record