about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-12-27 07:18:49 +0000
committerEric Wong <normalperson@yhbt.net>2010-12-27 07:34:21 +0000
commit3a250fcfb9fcfa0ab3a8105821e670563025faa4 (patch)
tree2105314936e65bd9a9a18f1f7908ba99f221bbd9 /lib
parent2873361069dc2f8c793875316a0a2c9b8fa54761 (diff)
downloadrainbows-3a250fcfb9fcfa0ab3a8105821e670563025faa4.tar.gz
Cool.io is the new name for Rev.  We'll continue to support Rev
until Cool.io breaks backwards compatibility.  Rev may not be
supported if Cool.io is.
Diffstat (limited to 'lib')
-rw-r--r--lib/rainbows.rb8
-rw-r--r--lib/rainbows/app_pool.rb3
-rw-r--r--lib/rainbows/coolio.rb2
-rw-r--r--lib/rainbows/coolio_fiber_spawn.rb2
-rw-r--r--lib/rainbows/coolio_thread_pool.rb2
-rw-r--r--lib/rainbows/coolio_thread_spawn.rb2
-rw-r--r--lib/rainbows/dev_fd_response.rb2
-rw-r--r--lib/rainbows/fiber/rev.rb7
-rw-r--r--lib/rainbows/http_server.rb3
-rw-r--r--lib/rainbows/max_body.rb4
-rw-r--r--lib/rainbows/rev.rb10
11 files changed, 36 insertions, 9 deletions
diff --git a/lib/rainbows.rb b/lib/rainbows.rb
index 1f8b252..dd5a5b2 100644
--- a/lib/rainbows.rb
+++ b/lib/rainbows.rb
@@ -60,7 +60,7 @@ module Rainbows
       case G.server.use
       when :FiberPool, :FiberSpawn
         Rainbows::Fiber.sleep(nr)
-      when :RevFiberSpawn
+      when :RevFiberSpawn, :CoolioFiberSpawn
         Rainbows::Fiber::Rev::Sleeper.new(nr)
       when :Revactor
         Actor.sleep(nr)
@@ -98,12 +98,16 @@ module Rainbows
     :Rev => 50,
     :RevThreadSpawn => 50,
     :RevThreadPool => 50,
+    :RevFiberSpawn => 50,
+    :Coolio => 50,
+    :CoolioThreadSpawn => 50,
+    :CoolioThreadPool => 50,
+    :CoolioFiberSpawn => 50,
     :EventMachine => 50,
     :FiberSpawn => 50,
     :FiberPool => 50,
     :ActorSpawn => 50,
     :NeverBlock => 50,
-    :RevFiberSpawn => 50,
   }.each do |model, _|
     u = model.to_s.gsub(/([a-z0-9])([A-Z0-9])/) { "#{$1}_#{$2.downcase!}" }
     autoload model, "rainbows/#{u.downcase!}"
diff --git a/lib/rainbows/app_pool.rb b/lib/rainbows/app_pool.rb
index b406b32..44c6bf5 100644
--- a/lib/rainbows/app_pool.rb
+++ b/lib/rainbows/app_pool.rb
@@ -88,7 +88,8 @@ class Rainbows::AppPool < Struct.new(:pool, :re)
     # concurrency models
     self.re ||= begin
       case env["rainbows.model"]
-      when :FiberSpawn, :FiberPool, :Revactor, :NeverBlock, :RevFiberSpawn
+      when :FiberSpawn, :FiberPool, :Revactor, :NeverBlock,
+           :RevFiberSpawn, :CoolioFiberSpawn
         self.pool = Rainbows::Fiber::Queue.new(pool)
       end
       true
diff --git a/lib/rainbows/coolio.rb b/lib/rainbows/coolio.rb
new file mode 100644
index 0000000..fb0a305
--- /dev/null
+++ b/lib/rainbows/coolio.rb
@@ -0,0 +1,2 @@
+# :enddoc:
+Rainbows.const_set(:Coolio, Rainbows::Rev)
diff --git a/lib/rainbows/coolio_fiber_spawn.rb b/lib/rainbows/coolio_fiber_spawn.rb
new file mode 100644
index 0000000..272d111
--- /dev/null
+++ b/lib/rainbows/coolio_fiber_spawn.rb
@@ -0,0 +1,2 @@
+# :enddoc:
+Rainbows.const_set(:CoolioFiberSpawn, Rainbows::RevFiberSpawn)
diff --git a/lib/rainbows/coolio_thread_pool.rb b/lib/rainbows/coolio_thread_pool.rb
new file mode 100644
index 0000000..acb1bdb
--- /dev/null
+++ b/lib/rainbows/coolio_thread_pool.rb
@@ -0,0 +1,2 @@
+# :enddoc:
+Rainbows.const_set(:CoolioThreadPool, Rainbows::RevThreadSpawn)
diff --git a/lib/rainbows/coolio_thread_spawn.rb b/lib/rainbows/coolio_thread_spawn.rb
new file mode 100644
index 0000000..1ca5c6c
--- /dev/null
+++ b/lib/rainbows/coolio_thread_spawn.rb
@@ -0,0 +1,2 @@
+# :enddoc:
+Rainbows.const_set(:CoolioThreadSpawn, Rainbows::RevThreadSpawn)
diff --git a/lib/rainbows/dev_fd_response.rb b/lib/rainbows/dev_fd_response.rb
index 67c94d7..175978b 100644
--- a/lib/rainbows/dev_fd_response.rb
+++ b/lib/rainbows/dev_fd_response.rb
@@ -53,7 +53,7 @@ class Rainbows::DevFdResponse < Struct.new(:app)
 
       # we need to make sure our pipe output is Fiber-compatible
       case env["rainbows.model"]
-      when :FiberSpawn, :FiberPool, :RevFiberSpawn
+      when :FiberSpawn, :FiberPool, :RevFiberSpawn, :CoolioFiberSpawn
         io.respond_to?(:kgio_wait_readable) or
           io = Rainbows::Fiber::IO.new(io)
       when :Revactor
diff --git a/lib/rainbows/fiber/rev.rb b/lib/rainbows/fiber/rev.rb
index 85d1c5f..be1b3d9 100644
--- a/lib/rainbows/fiber/rev.rb
+++ b/lib/rainbows/fiber/rev.rb
@@ -1,6 +1,11 @@
 # -*- encoding: binary -*-
 # :enddoc:
-require 'rev'
+begin
+  require 'coolio'
+rescue LoadError
+  require 'rev'
+end
+require 'rev' if defined?(Coolio)
 require 'rainbows/fiber'
 require 'rainbows/fiber/io'
 
diff --git a/lib/rainbows/http_server.rb b/lib/rainbows/http_server.rb
index 33aa309..d02af72 100644
--- a/lib/rainbows/http_server.rb
+++ b/lib/rainbows/http_server.rb
@@ -74,7 +74,8 @@ class Rainbows::HttpServer < Unicorn::HttpServer
     new_defaults = {
       'rainbows.model' => (@use = model.to_sym),
       'rack.multithread' => !!(model.to_s =~ /Thread/),
-      'rainbows.autochunk' => [:Rev,:EventMachine,:NeverBlock].include?(@use),
+      'rainbows.autochunk' => [:Coolio,:Rev,
+                               :EventMachine,:NeverBlock].include?(@use),
     }
     Rainbows::Const::RACK_DEFAULTS.update(new_defaults)
   end
diff --git a/lib/rainbows/max_body.rb b/lib/rainbows/max_body.rb
index 9c9539f..878b04d 100644
--- a/lib/rainbows/max_body.rb
+++ b/lib/rainbows/max_body.rb
@@ -53,7 +53,9 @@ class Rainbows::MaxBody
   def self.setup # :nodoc:
     Rainbows.max_bytes or return
     case Rainbows::G.server.use
-    when :Rev, :EventMachine, :NeverBlock, :RevThreadSpawn, :RevThreadPool
+    when :Rev, :Coolio, :EventMachine, :NeverBlock,
+         :RevThreadSpawn, :RevThreadPool,
+         :CoolioThreadSpawn, :CoolioThreadPool
       return
     end
 
diff --git a/lib/rainbows/rev.rb b/lib/rainbows/rev.rb
index 6ddb130..cb4701b 100644
--- a/lib/rainbows/rev.rb
+++ b/lib/rainbows/rev.rb
@@ -1,6 +1,12 @@
 # -*- encoding: binary -*-
-require 'rev'
-Rev::VERSION >= '0.3.0' or abort 'rev >= 0.3.0 is required'
+begin
+  require 'coolio'
+  Coolio::VERSION >= '1.0.0' or abort 'cool.io >= 1.0.0 is required'
+rescue LoadError
+  require 'rev'
+  Rev::VERSION >= '0.3.0' or abort 'rev >= 0.3.0 is required'
+end
+require 'rev' if defined?(Coolio)
 
 # Implements a basic single-threaded event model with
 # {Rev}[http://rev.rubyforge.org/].  It is capable of handling