epoll+xepoll: clarify intent of these concurrency options
[rainbows.git] / lib / rainbows / epoll.rb
blob4fbf9baec3a94d04df4f16ebabf65b23ed85a76b
1 # -*- encoding: binary -*-
2 require 'sleepy_penguin'
3 require 'sendfile'
5 # Edge-triggered epoll concurrency model using
6 # {sleepy_penguin}[http://bogomips.org/sleepy_penguin/] for epoll.
8 # Unlike more portable options like Coolio and EventMachine, this
9 # is Linux-only, but uses edge-triggering instead of level-triggering,
10 # so it may perform better in some cases.  Coolio and EventMachine have
11 # better library support and may be widely-used, however.
13 # Consider using XEpoll instead of this if you are using Ruby 1.9,
14 # it will avoid accept()-scalability issues with many worker processes.
16 # When serving static files, this is extremely unfair and optimized
17 # for throughput at the expense of fairness.  This is not an issue
18 # if you're not serving static files, or if your working set is
19 # small enough to always be in your kernel page cache.  This concurrency
20 # model may starve clients if you have slow disks and large static files.
22 # Do not use this if you have slow external dependencies.
24 # === RubyGem Requirements
26 # * raindrops 0.6.0 or later
27 # * sleepy_penguin 3.0.1 or later
28 # * sendfile 1.1.0 or later
30 module Rainbows::Epoll
31   # :stopdoc:
32   include Rainbows::Base
33   autoload :Server, 'rainbows/epoll/server'
34   autoload :Client, 'rainbows/epoll/client'
35   autoload :ResponsePipe, 'rainbows/epoll/response_pipe'
36   autoload :ResponseChunkPipe, 'rainbows/epoll/response_chunk_pipe'
38   def init_worker_process(worker)
39     super
40     Rainbows.const_set(:EP, SleepyPenguin::Epoll.new)
41     Rainbows::Client.__send__ :include, Client
42     LISTENERS.each { |io| io.extend(Server) }
43   end
45   def worker_loop(worker) # :nodoc:
46     init_worker_process(worker)
47     Client.loop
48   end
49   # :startdoc:
50 end