client: use kgio_write across the board
[rainbows.git] / lib / rainbows / never_block.rb
blob51ca904b819fa5a138e266dec6f6588866f3ea89
1 # -*- encoding: binary -*-
3 # {NeverBlock}[www.espace.com.eg/neverblock/] library that combines
4 # the EventMachine library with Ruby Fibers.  This includes use of
5 # Thread-based Fibers under Ruby 1.8.  It currently does NOT support
6 # a streaming "rack.input" but is compatible with everything else
7 # EventMachine supports.
9 # === :pool_size vs worker_connections
11 # In your Rainbows! config block, you may specify a Fiber pool size
12 # to limit your application concurrency (without using Rainbows::AppPool)
13 # independently of worker_connections.
15 #   Rainbows! do
16 #     use :NeverBlock, :pool_size => 50
17 #     worker_connections 100
18 #   end
20 module Rainbows::NeverBlock
21   # :stopdoc:
22   extend Rainbows::PoolSize
24   # same pool size NB core itself uses
25   def self.setup # :nodoc:
26     super
27     Rainbows::O[:backend] ||= :EventMachine # no Cool.io support, yet
28     Rainbows.const_get(Rainbows::O[:backend])
29     require "never_block" # require EM first since we need a higher version
30   end
32   def self.extended(klass)
33     klass.extend(Rainbows.const_get(Rainbows::O[:backend])) # EventMachine
34     klass.extend(Rainbows::NeverBlock::Core)
35   end
36   # :startdoc:
37 end
38 # :enddoc:
39 require 'rainbows/never_block/core'