epoll: handle EINTR properly in Ruby-space
[rainbows.git] / lib / rainbows / epoll.rb
blobc8c013e2d7be3c9bc7b572cee05b3c1cc94081c6
1 # -*- encoding: binary -*-
2 # :enddoc:
3 require 'sleepy_penguin'
4 require 'sendfile'
6 # Edge-triggered epoll concurrency model.  This is extremely unfair
7 # and optimized for throughput at the expense of fairness
8 module Rainbows::Epoll
9   include Rainbows::Base
10   autoload :Server, 'rainbows/epoll/server'
11   autoload :Client, 'rainbows/epoll/client'
12   autoload :ResponsePipe, 'rainbows/epoll/response_pipe'
13   autoload :ResponseChunkPipe, 'rainbows/epoll/response_chunk_pipe'
15   def init_worker_process(worker)
16     super
17     Rainbows::Epoll.const_set :EP, SleepyPenguin::Epoll.new
18     Rainbows::Client.__send__ :include, Client
19   end
21   def worker_loop(worker) # :nodoc:
22     init_worker_process(worker)
23     Server.run
24   end
25 end