diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2012-05-07 09:47:09 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2012-05-07 11:59:57 +0200 |
commit | 3544d3c67de7976a31fdaaadb6ce10d0c7055ad1 (patch) | |
tree | c711ec43548ee5e6666518de592a87ed5782315f | |
parent | 34da35e17a77b295d2761775f3a93d51fb55f9e3 (diff) | |
download | edoors-ruby-3544d3c67de7976a31fdaaadb6ce10d0c7055ad1.zip edoors-ruby-3544d3c67de7976a31fdaaadb6ce10d0c7055ad1.tar.gz |
Twirl: add @run, break loop after each @app_fifo process to check @sys_fifo
-rw-r--r-- | lib/evendoors/space.rb | 1 | ||||
-rw-r--r-- | 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 |