From 90a86c9822238f01e8d60c9303b9a0da64351c7f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 5 Feb 2011 10:44:52 +0000 Subject: *epoll: refactor common loop code acceptor thread pools could use some work, still --- lib/rainbows/join_threads.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 lib/rainbows/join_threads.rb (limited to 'lib/rainbows/join_threads.rb') diff --git a/lib/rainbows/join_threads.rb b/lib/rainbows/join_threads.rb new file mode 100644 index 0000000..6636e7c --- /dev/null +++ b/lib/rainbows/join_threads.rb @@ -0,0 +1,18 @@ +# -*- encoding: binary -*- +# :nodoc: +# This module only gets loaded on shutdown +module Rainbows::JoinThreads + + # blocking acceptor threads must be forced to run + def self.acceptors(threads) + threads.delete_if do |thr| + Rainbows.tick + begin + thr.run + thr.join(0.01) + rescue + true + end + end until threads.empty? + end +end -- cgit v1.2.3-24-ge0c7