From 5451f0c20d2382ac126e923179c096357d20cf0a Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 19 Jul 2010 10:09:58 +0000 Subject: event_machine: split out uncommonly used modules Some applications may not use Response*Pipe and TryDefer at all, so there's no reason to pollute the runtime with extra nodes to mark during GC. --- lib/rainbows/event_machine/response_chunk_pipe.rb | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lib/rainbows/event_machine/response_chunk_pipe.rb (limited to 'lib/rainbows/event_machine/response_chunk_pipe.rb') diff --git a/lib/rainbows/event_machine/response_chunk_pipe.rb b/lib/rainbows/event_machine/response_chunk_pipe.rb new file mode 100644 index 0000000..ee8d260 --- /dev/null +++ b/lib/rainbows/event_machine/response_chunk_pipe.rb @@ -0,0 +1,25 @@ +# -*- encoding: binary -*- +# :enddoc: +module Rainbows::EventMachine::ResponseChunkPipe + include Rainbows::EventMachine::ResponsePipe + + def unbind + @client.write("0\r\n\r\n") + super + end + + def notify_readable + begin + data = @io.read_nonblock(16384, BUF) + @client.write(sprintf("%x\r\n", data.size)) + @client.write(data) + @client.write("\r\n") + rescue Errno::EINTR + rescue Errno::EAGAIN + return + rescue EOFError + detach + return + end while true + end +end -- cgit v1.2.3-24-ge0c7