about summary refs log tree commit homepage
path: root/lib/rainbows/rev_thread_pool.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-12-28 17:59:27 -0800
committerEric Wong <normalperson@yhbt.net>2010-12-28 18:00:04 -0800
commit40445641f11f01c6a24bf96c8b80eed5fd33a512 (patch)
tree57a7652cc03f46407d51babfd04d72d1c401ac99 /lib/rainbows/rev_thread_pool.rb
parent3495d59763e6159975debf32728dc53fc41c5ea1 (diff)
downloadrainbows-40445641f11f01c6a24bf96c8b80eed5fd33a512.tar.gz
complete Rev => Coolio renaming
We use Cool.io internally everywhere now, but preserve
Rev-based models for anybody using them.
Diffstat (limited to 'lib/rainbows/rev_thread_pool.rb')
-rw-r--r--lib/rainbows/rev_thread_pool.rb45
1 files changed, 4 insertions, 41 deletions
diff --git a/lib/rainbows/rev_thread_pool.rb b/lib/rainbows/rev_thread_pool.rb
index 4366086..844651a 100644
--- a/lib/rainbows/rev_thread_pool.rb
+++ b/lib/rainbows/rev_thread_pool.rb
@@ -1,4 +1,7 @@
 # -*- encoding: binary -*-
+# :stopdoc:
+Rainbows.const_set(:RevThreadPool, Rainbows::CoolioThreadPool)
+# :startdoc:
 
 # CoolioThreadPool is the new version of this, use that instead.
 #
@@ -16,44 +19,4 @@
 #
 # This concurrency model is designed for Ruby 1.9, and Ruby 1.8
 # users are NOT advised to use this due to high CPU usage.
-module Rainbows::RevThreadPool
-
-  # :stopdoc:
-  DEFAULTS = {
-    :pool_size => 20, # same default size as ThreadPool (w/o Rev)
-  }
-  #:startdoc:
-
-  def self.setup # :nodoc:
-    o = Rainbows::O
-    DEFAULTS.each { |k,v| o[k] ||= v }
-    Integer === o[:pool_size] && o[:pool_size] > 0 or
-      raise ArgumentError, "pool_size must a be an Integer > 0"
-  end
-  include Rainbows::Rev::Core
-
-  def init_worker_threads(master, queue) # :nodoc:
-    Rainbows::O[:pool_size].times.map do
-      Thread.new do
-        begin
-          client = queue.pop
-          master << [ client, client.app_response ]
-        rescue => e
-          Rainbows::Error.listen_loop(e)
-        end while true
-      end
-    end
-  end
-
-  def init_worker_process(worker) # :nodoc:
-    super
-    master = Rainbows::Rev::Master.new(Queue.new).attach(Rev::Loop.default)
-    queue = Rainbows::RevThreadPool::Client.const_set(:QUEUE, Queue.new)
-    threads = init_worker_threads(master, queue)
-    Rainbows::RevThreadPool::Watcher.new(threads).attach(Rev::Loop.default)
-    logger.info "RevThreadPool pool_size=#{Rainbows::O[:pool_size]}"
-  end
-end
-# :enddoc:
-require 'rainbows/rev_thread_pool/client'
-require 'rainbows/rev_thread_pool/watcher'
+module Rainbows::RevThreadPool; end