about summary refs log tree commit homepage
path: root/lib/rainbows/join_threads.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-02-05 10:44:52 +0000
committerEric Wong <normalperson@yhbt.net>2011-02-05 11:13:43 +0000
commit90a86c9822238f01e8d60c9303b9a0da64351c7f (patch)
treeb13a4384b526887c964f74b1b9e2a2927e5b86bd /lib/rainbows/join_threads.rb
parentc9ca82c76f1eb0e06b0aa204a243d00f382579c5 (diff)
downloadrainbows-90a86c9822238f01e8d60c9303b9a0da64351c7f.tar.gz
acceptor thread pools could use some work, still
Diffstat (limited to 'lib/rainbows/join_threads.rb')
-rw-r--r--lib/rainbows/join_threads.rb18
1 files changed, 18 insertions, 0 deletions
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