From 37a560c5d14c15a3da7f2c10c9ea3d6002b34fe1 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 28 Nov 2009 19:42:53 -0800 Subject: refactor threaded models to use blocking accept() if possible It's a tad faster for non-keepalive connections and should do better on large SMP machines with many workers AND threads. That means the ActorSpawn model in Rubinius is nothing more than ThreadSpawn underneath (for now). --- lib/rainbows/base.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'lib/rainbows/base.rb') diff --git a/lib/rainbows/base.rb b/lib/rainbows/base.rb index 4be37f4..7ee5c03 100644 --- a/lib/rainbows/base.rb +++ b/lib/rainbows/base.rb @@ -70,15 +70,11 @@ module Rainbows end def join_threads(threads) - G.quit! expire = Time.now + (timeout * 2.0) - until (threads.delete_if { |thr| ! thr.alive? }).empty? - threads.each { |thr| - G.tick - thr.join(1) - break if Time.now >= expire - } + until threads.empty? || Time.now >= expire + threads.delete_if { |thr| thr.alive? ? thr.join(0.01) : true } end + exit!(0) unless threads.empty? end def self.included(klass) -- cgit v1.2.3-24-ge0c7