repo.or.cz
/
rainbows.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
history
|
raw
|
HEAD
globally refactor Range handling for responses
[rainbows.git]
/
lib
/
rainbows
/
fiber
/
coolio
/
server.rb
blob
b0649532200c502f409ecf2c64ade6010c1d5bfd
1
# -*- encoding: binary -*-
2
# :enddoc:
3
class Rainbows::Fiber::Coolio::Server < Coolio::IOWatcher
4
G = Rainbows::G
5
6
def to_io
7
@io
8
end
9
10
def initialize(io)
11
@io = io
12
super(self, :r)
13
end
14
15
def close
16
detach if attached?
17
@io.close
18
end
19
20
def on_readable
21
return if G.cur >= MAX
22
c = @io.kgio_tryaccept and Fiber.new { process(c) }.resume
23
end
24
25
def process(io)
26
G.cur += 1
27
io.process_loop
28
ensure
29
G.cur -= 1
30
end
31
end