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
doc: add HACKING document
[rainbows.git]
/
lib
/
rainbows
/
fiber
/
coolio
/
server.rb
blob
3d8d85ee9fd51b1a69a63a2e2b65410b263fddde
1
# -*- encoding: binary -*-
2
# :enddoc:
3
class Rainbows::Fiber::Coolio::Server < Coolio::IOWatcher
4
def to_io
5
@io
6
end
7
8
def initialize(io)
9
@io = io
10
super(self, :r)
11
end
12
13
def close
14
detach if attached?
15
@io.close
16
end
17
18
def on_readable
19
return if Rainbows.cur >= MAX
20
c = @io.kgio_tryaccept and Fiber.new { process(c) }.resume
21
end
22
23
def process(io)
24
Rainbows.cur += 1
25
io.process_loop
26
ensure
27
Rainbows.cur -= 1
28
end
29
end