tests: "wc -c" portability for *BSDs
[rainbows.git] / lib / rainbows / xepoll_thread_spawn.rb
blob2f719063f1452e6a32a84d18a1f7f97d0c19b562
1 # -*- encoding: binary -*-
2 require "thread"
3 require "sleepy_penguin"
4 require "raindrops"
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+
15 # === Disadvantages
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
28 # clients.
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
44   # :stopdoc:
45   include Rainbows::Base
47   def init_worker_process(worker)
48     super
49     require "rainbows/xepoll_thread_spawn/client"
50     Rainbows::Client.__send__ :include, Client
51   end
53   def worker_loop(worker) # :nodoc:
54     init_worker_process(worker)
55     Client.loop
56   end
57   # :startdoc:
58 end