1 # -*- encoding: binary -*-
3 require "sleepy_penguin"
6 # This is an edge-triggered epoll concurrency model with blocking
7 # accept() in a (hopefully) native thread. This is comparable to
8 # ThreadSpawn and CoolioThreadSpawn, but is Linux-only and able to exploit
9 # "wake one" accept() behavior of a blocking accept() call when used
10 # with native threads.
12 # This supports streaming "rack.input" and allows +:pool_size+ tuning
13 # independently of +worker_connections+
17 # This is only supported under Linux 2.6 and later kernels.
19 # === Compared to CoolioThreadSpawn
21 # This does not buffer outgoing responses in userspace at all, meaning
22 # it can lower response latency to fast clients and also prevent
23 # starvation of other clients when reading slow disks for responses
24 # (when combined with native threads).
26 # CoolioThreadSpawn is likely better for trickling large static files or
27 # proxying responses to slow clients, but this is likely better for fast
30 # Unlikely CoolioThreadSpawn, this supports streaming "rack.input" which
31 # is useful for reading large uploads from fast clients.
33 # === Compared to ThreadSpawn
35 # This can maintain idle connections without the memory overhead of an
36 # idle Thread. The cost of handling/dispatching active connections is
37 # exactly the same for an equivalent number of active connections.
39 # === RubyGem Requirements
41 # * raindrops 0.6.0 or later
42 # * sleepy_penguin 3.0.1 or later
43 module Rainbows::XEpollThreadSpawn
45 include Rainbows::Base
47 def init_worker_process(worker)
49 require "rainbows/xepoll_thread_spawn/client"
50 Rainbows::Client.__send__ :include, Client
53 def worker_loop(worker) # :nodoc:
54 init_worker_process(worker)