Separate example Ruby code
This commit is contained in:
parent
fef310d35c
commit
95a1c98fb8
27
ruby/example.rb
Normal file
27
ruby/example.rb
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
$LOAD_PATH << '.'
|
||||||
|
require "jsh"
|
||||||
|
|
||||||
|
def main
|
||||||
|
s = Stream.new $stdout, 4
|
||||||
|
s.start!
|
||||||
|
7.times do |i|
|
||||||
|
proc = {:pid => i + 1, :name => "init"}
|
||||||
|
s.output(:things, proc)
|
||||||
|
end
|
||||||
|
q = s.new_stream 'q'
|
||||||
|
q.output(:test, 'potato')
|
||||||
|
|
||||||
|
10.times do |i|
|
||||||
|
proc = {:pid => i + 1, :name => "init"}
|
||||||
|
s.output(:processes, proc)
|
||||||
|
end
|
||||||
|
|
||||||
|
q.output(:test, "salad")
|
||||||
|
q.output(:test, "rocks")
|
||||||
|
|
||||||
|
s.flush
|
||||||
|
s.stop!
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
main
|
25
ruby/jsh.rb
25
ruby/jsh.rb
@ -118,28 +118,3 @@ class Stream
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def main
|
|
||||||
s = Stream.new $stdout, 4
|
|
||||||
s.start!
|
|
||||||
7.times do |i|
|
|
||||||
proc = {:pid => i + 1, :name => "init"}
|
|
||||||
s.output(:things, proc)
|
|
||||||
end
|
|
||||||
q = s.new_stream 'q'
|
|
||||||
q.output(:test, 'potato')
|
|
||||||
|
|
||||||
10.times do |i|
|
|
||||||
proc = {:pid => i + 1, :name => "init"}
|
|
||||||
s.output(:processes, proc)
|
|
||||||
end
|
|
||||||
|
|
||||||
q.output(:test, "salad")
|
|
||||||
q.output(:test, "rocks")
|
|
||||||
|
|
||||||
s.flush
|
|
||||||
s.stop!
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
main
|
|
Reference in New Issue
Block a user