Skip to content
Browse files

Allow varying N in Sieve

  • Loading branch information...
1 parent 8bf1758 commit 872cf1b58944cfaaeaf17da1646a09a22e986603 @dasch committed Jun 2, 2010
Showing with 6 additions and 2 deletions.
  1. +3 −1 examples/fiber-sieve.rb
  2. +3 −1 examples/sieve.rb
View
4 examples/fiber-sieve.rb
@@ -1,6 +1,8 @@
require 'fiber'
+N = ARGV[0] ? Integer(ARGV[0]) : 2000
+
PRINTER = Fiber.new do |i|
while true
puts i
@@ -26,6 +28,6 @@ def worker
WORKER = worker
-(2..2000).each do |i|
+(2..N).each do |i|
WORKER.resume(i)
end
View
4 examples/sieve.rb
@@ -32,10 +32,12 @@ def worker(cin, cout)
end
end
+N = ARGV[0] ? Integer(ARGV[0]) : 2000
+
JOBS = Minx.channel
RESULTS = Minx.channel
printer(RESULTS)
worker(JOBS, RESULTS)
-Minx.join(generate(2..2000, JOBS))
+Minx.join(generate(2..N, JOBS))

0 comments on commit 872cf1b

Please sign in to comment.
Something went wrong with that request. Please try again.