From e867a6d1a612baf7975b14f9bffa14ea8b05f35c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 4 Jul 2010 07:40:58 +0000 Subject: thread_pool: force threads to wakeup on shutdown We may use a blocking accept() loop if there is only a single listener. In that case threads may not be able to exit if a SIGQUIT is received, so force them to run when joining. --- lib/rainbows/thread_pool.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/rainbows/thread_pool.rb b/lib/rainbows/thread_pool.rb index 6fce3c1..f609483 100644 --- a/lib/rainbows/thread_pool.rb +++ b/lib/rainbows/thread_pool.rb @@ -70,7 +70,12 @@ module Rainbows G.quit! threads.delete_if do |thr| G.tick - thr.alive? ? thr.join(0.01) : true + begin + thr.run + thr.join(0.01) + rescue + true + end end until threads.empty? end -- cgit v1.2.3-24-ge0c7