initial XAcceptEpoll concurrency model
[rainbows.git] / lib / rainbows / xaccept_epoll.rb
blob0690c074e1f5a3133caf784a004e9f0cbbda7e1b
1 # -*- encoding: binary -*-
2 # :enddoc:
3 require 'raindrops'
4 require 'rainbows/epoll'
6 # Edge-triggered epoll concurrency model with blocking accept() in
7 # a (hopefully) native thread.  This is recommended over Epoll for
8 # Ruby 1.9 users as it can workaround accept()-scalability issues
9 # on multicore machines.
10 module Rainbows::XAcceptEpoll
11   include Rainbows::Base
12   autoload :Client, 'rainbows/xaccept_epoll/client'
14   def init_worker_process(worker)
15     super
16     Rainbows::Epoll.const_set :EP, SleepyPenguin::Epoll.new
17     trap(:QUIT) { Rainbows::Epoll.quit! }
18     Rainbows::Client.__send__ :include, Client
19   end
21   def worker_loop(worker) # :nodoc:
22     init_worker_process(worker)
23     Client.run
24   end
25 end