From 31a93152c8977f31045bd182ae99df4ebd088abf Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 5 Jan 2011 17:18:05 -0800 Subject: minor cleanups following state cleanups We noticed a few more things that could be cleaned up after the last commit. --- lib/rainbows/thread_spawn.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/rainbows/thread_spawn.rb') 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: -- cgit v1.2.3-24-ge0c7