bump required Unicorn dependency for Kgio
[rainbows.git] / lib / rainbows / epoll / response_pipe.rb
blob56d9a478e1e5139d66469e115af4d535d140a515
1 # -*- encoding: binary -*-
2 # :enddoc:
4 class Rainbows::Epoll::ResponsePipe
5   attr_reader :io
6   alias to_io io
7   RBUF = Rainbows::EvCore::RBUF
8   EP = Rainbows::Epoll::EP
10   def initialize(io, client, body)
11     @io, @client, @body = io, client, body
12   end
14   def epoll_run
15     return close if @client.closed?
16     @client.stream_pipe(self) or @client.on_deferred_write_complete
17     rescue => e
18       close
19       @client.handle_error(e)
20   end
22   def close
23     @io or return
24     EP.delete self
25     @body.respond_to?(:close) and @body.close
26     @io = @body = nil
27   end
29   def tryread
30     Kgio.tryread(@io, 16384, RBUF)
31   end
32 end