summaryrefslogtreecommitdiffstats
path: root/lib/evendoors
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2012-05-10 08:47:02 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2012-05-10 08:47:02 +0200
commit274411458b30ba08a9e0adca0a0f5820e9a8648f (patch)
tree7f896cd7b30998c53b000e03ca7d1c66ef6f502c /lib/evendoors
parentf72393c031018d224318fb4aeff16b6e6c330327 (diff)
downloadedoors-ruby-274411458b30ba08a9e0adca0a0f5820e9a8648f.zip
edoors-ruby-274411458b30ba08a9e0adca0a0f5820e9a8648f.tar.gz
Twirl merge with Space -> Spin is born
Diffstat (limited to 'lib/evendoors')
-rw-r--r--lib/evendoors/board.rb2
-rw-r--r--lib/evendoors/door.rb8
-rw-r--r--lib/evendoors/room.rb32
-rw-r--r--lib/evendoors/space.rb26
-rw-r--r--lib/evendoors/spin.rb (renamed from lib/evendoors/twirl.rb)21
5 files changed, 38 insertions, 51 deletions
diff --git a/lib/evendoors/board.rb b/lib/evendoors/board.rb
index 3cc2240..36ca332 100644
--- a/lib/evendoors/board.rb
+++ b/lib/evendoors/board.rb
@@ -23,7 +23,7 @@ module EvenDoors
@saved = p
receive_p p
if not @saved.nil?
- puts "#{path} didn't give that particle back #{p}" if EvenDoors::Twirl.debug_errors
+ puts "#{path} didn't give that particle back #{p}" if EvenDoors::Spin.debug_errors
puts "\t#{p.data EvenDoors::ERROR_FIELD}" if p.action==EvenDoors::ACT_ERROR
release_p @saved
@saved = nil
diff --git a/lib/evendoors/door.rb b/lib/evendoors/door.rb
index 6118a27..0fe3867 100644
--- a/lib/evendoors/door.rb
+++ b/lib/evendoors/door.rb
@@ -13,14 +13,14 @@ module EvenDoors
end
#
def require_p p_kls
- p = EvenDoors::Twirl.require_p p_kls
+ p = EvenDoors::Spin.require_p p_kls
p.src = self
p
end
#
def release_p p
@saved=nil if @saved==p # particle is released, all is good
- EvenDoors::Twirl.release_p p
+ EvenDoors::Spin.release_p p
end
#
def process_p p
@@ -28,7 +28,7 @@ module EvenDoors
@saved = p
receive_p p
if not @saved.nil?
- puts "#{path} didn't give that particle back #{p}" if EvenDoors::Twirl.debug_errors
+ puts "#{path} didn't give that particle back #{p}" if EvenDoors::Spin.debug_errors
puts "\t#{p.data EvenDoors::ERROR_FIELD}" if p.action==EvenDoors::ACT_ERROR
release_p @saved
@saved = nil
@@ -37,7 +37,7 @@ module EvenDoors
#
def process_sys_p p
# nothing todo with it now
- EvenDoors::Twirl.release_p p
+ EvenDoors::Spin.release_p p
end
#
def send_p p
diff --git a/lib/evendoors/room.rb b/lib/evendoors/room.rb
index bc9ee63..d06c00f 100644
--- a/lib/evendoors/room.rb
+++ b/lib/evendoors/room.rb
@@ -28,22 +28,22 @@ module EvenDoors
end
#
def start!
- puts " * start #{path}" if EvenDoors::Twirl.debug_routing
+ puts " * start #{path}" if EvenDoors::Spin.debug_routing
@spots.values.each do |spot| spot.start! if spot.respond_to? :start! end
end
#
def stop!
- puts " * stop #{path}" if EvenDoors::Twirl.debug_routing
+ puts " * stop #{path}" if EvenDoors::Spin.debug_routing
@spots.values.each do |spot| spot.stop! if spot.respond_to? :stop! end
end
#
- def space
- return @space if @space
- @space = ( @parent.nil? ? self : @parent.space )
+ def spin
+ return @spin if @spin
+ @spin = ( @parent.nil? ? self : @parent.spin )
end
#
def try_links p
- puts " -> try_links ..." if EvenDoors::Twirl.debug_routing
+ puts " -> try_links ..." if EvenDoors::Spin.debug_routing
links = @links[p.src.name]
return false if links.nil?
pending_link = nil
@@ -54,7 +54,7 @@ module EvenDoors
if apply_link or (p.link_value==link.cond_value)
# link matches !
if pending_link
- p2 = EvenDoors::Twirl.require_p p.class
+ p2 = EvenDoors::Spin.require_p p.class
p2.clone_data p
p2.apply_link! link
send_p p2
@@ -87,10 +87,10 @@ module EvenDoors
end
#
def send_p p
- puts " * send_p #{(p.next_dst.nil? ? 'no dst' : p.next_dst)} ..." if EvenDoors::Twirl.debug_routing
+ puts " * send_p #{(p.next_dst.nil? ? 'no dst' : p.next_dst)} ..." if EvenDoors::Spin.debug_routing
if p.src.nil?
# do not route orphan particles !!
- p.error! EvenDoors::ERROR_ROUTE_NS, space
+ p.error! EvenDoors::ERROR_ROUTE_NS, spin
elsif p.next_dst
p.split_dst!
if p.door
@@ -104,31 +104,31 @@ module EvenDoors
else
p.error! EvenDoors::ERROR_ROUTE_NDNL
end
- puts " -> #{p.dst.path}#{EvenDoors::ACT_SEP}#{p.action}" if EvenDoors::Twirl.debug_routing
- EvenDoors::Twirl.send_p p
+ puts " -> #{p.dst.path}#{EvenDoors::ACT_SEP}#{p.action}" if EvenDoors::Spin.debug_routing
+ EvenDoors::Spin.send_p p
end
#
def send_sys_p p
- puts " * send_sys_p #{(p.next_dst.nil? ? 'no dst' : p.next_dst)} ..." if EvenDoors::Twirl.debug_routing
+ puts " * send_sys_p #{(p.next_dst.nil? ? 'no dst' : p.next_dst)} ..." if EvenDoors::Spin.debug_routing
if p.next_dst
p.split_dst!
if p.door
route_p p
elsif p.action
- p.dst_routed! space
+ p.dst_routed! spin
end
else
p.error! EvenDoors::ERROR_ROUTE_SND
end
- puts " -> #{p.dst.path}#{EvenDoors::ACT_SEP}#{p.action}" if EvenDoors::Twirl.debug_routing
- EvenDoors::Twirl.send_sys_p p
+ puts " -> #{p.dst.path}#{EvenDoors::ACT_SEP}#{p.action}" if EvenDoors::Spin.debug_routing
+ EvenDoors::Spin.send_sys_p p
end
#
def process_sys_p p
if p.action==EvenDoors::SYS_ACT_ADD_LINK
add_link EvenDoors::Link.from_particle_data p
end
- EvenDoors::Twirl.release_p p
+ EvenDoors::Spin.release_p p
end
#
end
diff --git a/lib/evendoors/space.rb b/lib/evendoors/space.rb
deleted file mode 100644
index da13065..0000000
--- a/lib/evendoors/space.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-#! /usr/bin/env ruby
-# -*- coding: UTF-8 -*-
-
-#
-module EvenDoors
- #
- class Space < Room
- #
- def initialize n, args={}
- super n, nil
- EvenDoors::Twirl.debug_errors = args[:debug_errors] || false
- EvenDoors::Twirl.debug_routing = args[:debug_routing] || false
- end
- #
- 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
- #
- end
- #
-end
-#
-# EOF
diff --git a/lib/evendoors/twirl.rb b/lib/evendoors/spin.rb
index cb01618..31904e8 100644
--- a/lib/evendoors/twirl.rb
+++ b/lib/evendoors/spin.rb
@@ -4,15 +4,15 @@
#
module EvenDoors
#
- class Twirl
+ class Spin < Room
#
- @debug_routing = false
- @debug_errors = false
@pool = {} # per particle class free list
@sys_fifo = [] # system particles fifo list
@app_fifo = [] # application particles fifo list
#
@run = false
+ @debug_routing = false
+ @debug_errors = false
#
class << self
#
@@ -43,7 +43,7 @@ module EvenDoors
@sys_fifo << p
end
#
- def twirl!
+ def spin!
while @run and (@sys_fifo.length>0 or @app_fifo.length>0)
while @run and @sys_fifo.length>0
p = @sys_fifo.shift
@@ -64,6 +64,19 @@ module EvenDoors
#
end
#
+ def initialize n, args={}
+ super n, nil
+ self.class.debug_errors = args[:debug_errors] || false
+ self.class.debug_routing = args[:debug_routing] || false
+ end
+ #
+ def spin!
+ @spots.values.each do |spot| spot.start! end
+ self.class.run = true
+ self.class.spin!
+ @spots.values.each do |spot| spot.stop! end
+ end
+ #
end
#
end