From 3544d3c67de7976a31fdaaadb6ce10d0c7055ad1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 7 May 2012 09:47:09 +0200 Subject: Twirl: add @run, break loop after each @app_fifo process to check @sys_fifo --- lib/evendoors/space.rb | 1 + lib/evendoors/twirl.rb | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/evendoors/space.rb b/lib/evendoors/space.rb index 6579003..22b9910 100644 --- a/lib/evendoors/space.rb +++ b/lib/evendoors/space.rb @@ -13,6 +13,7 @@ module EvenDoors # def twirl! @spots.values.each do |spot| spot.start! end + EvenDoors::Twirl.run = true EvenDoors::Twirl.twirl! @spots.values.each do |spot| spot.stop! end end diff --git a/lib/evendoors/twirl.rb b/lib/evendoors/twirl.rb index 8742220..9f38bf6 100644 --- a/lib/evendoors/twirl.rb +++ b/lib/evendoors/twirl.rb @@ -11,10 +11,11 @@ module EvenDoors @sys_fifo = [] # system particles fifo list @app_fifo = [] # application particles fifo list # + @run = false # class << self # - attr_accessor :debug + attr_accessor :debug, :run # def release_p p # hope there is no circular loop @@ -42,14 +43,15 @@ module EvenDoors end # def twirl! - while @sys_fifo.length>0 or @app_fifo.length>0 - while @sys_fifo.length>0 + while @run and (@sys_fifo.length>0 or @app_fifo.length>0) + while @run and @sys_fifo.length>0 p = @sys_fifo.shift p.door.process_sys_p p end - while @app_fifo.length>0 + while @run and @app_fifo.length>0 p = @app_fifo.shift p.door.process_p p + break end end end -- cgit v1.1-2-g2b99