1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
| | # -*- encoding: binary -*-
# :enddoc:
class Rainbows::Fiber::Rev::Server < Rev::IOWatcher
G = Rainbows::G
include Rainbows::ProcessClient
def to_io
@io
end
def initialize(io)
@io = io
super(self, :r)
end
def close
detach if attached?
@io.close
end
def on_readable
return if G.cur >= MAX
c = @io.kgio_tryaccept and Fiber.new { process(c) }.resume
end
def process(io)
G.cur += 1
process_client(io)
ensure
G.cur -= 1
end
end
|