about summary refs log tree commit homepage
path: root/lib/rainbows/thread_spawn.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-01-05 17:18:05 -0800
committerEric Wong <normalperson@yhbt.net>2011-01-06 14:14:30 -0800
commit31a93152c8977f31045bd182ae99df4ebd088abf (patch)
tree5e981f28e1a4e330bd8433b248a124fa07cb580d /lib/rainbows/thread_spawn.rb
parent6bde32081338ce8075854f4c47ce8ca5347df919 (diff)
downloadrainbows-31a93152c8977f31045bd182ae99df4ebd088abf.tar.gz
We noticed a few more things that could be cleaned
up after the last commit.
Diffstat (limited to 'lib/rainbows/thread_spawn.rb')
-rw-r--r--lib/rainbows/thread_spawn.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/rainbows/thread_spawn.rb b/lib/rainbows/thread_spawn.rb
index a0520d1..281e223 100644
--- a/lib/rainbows/thread_spawn.rb
+++ b/lib/rainbows/thread_spawn.rb
@@ -22,18 +22,19 @@ module Rainbows::ThreadSpawn
   def accept_loop(klass) #:nodoc:
     lock = Mutex.new
     limit = worker_connections
+    nr = 0
     LISTENERS.each do |l|
       klass.new(l) do |l|
         begin
-          if lock.synchronize { Rainbows.cur >= limit }
+          if lock.synchronize { nr >= limit }
             worker_yield
           elsif c = l.kgio_accept
             klass.new(c) do |c|
               begin
-                lock.synchronize { Rainbows.cur += 1 }
+                lock.synchronize { nr += 1 }
                 c.process_loop
               ensure
-                lock.synchronize { Rainbows.cur -= 1 }
+                lock.synchronize { nr -= 1 }
               end
             end
           end
@@ -42,7 +43,7 @@ module Rainbows::ThreadSpawn
         end while Rainbows.alive
       end
     end
-    sleep 1 while Rainbows.tick || lock.synchronize { Rainbows.cur > 0 }
+    sleep 1 while Rainbows.tick || lock.synchronize { nr > 0 }
   end
 
   def worker_loop(worker) #:nodoc: