upgrade to Kgio 2.x and Unicorn 3.x
[rainbows.git] / lib / rainbows / stream_file.rb
blob11c84d465cfe19043439df4b67a024e65064d418
1 # -*- encoding: binary -*-
2 # :enddoc:
4 # Used to keep track of file offsets in IO#sendfile_nonblock + evented
5 # models.  We always maintain our own file offsets in userspace because
6 # because sendfile() implementations offer pread()-like idempotency for
7 # concurrency (multiple clients can read the same underlying file handle).
8 class Rainbows::StreamFile < Struct.new(:offset, :count, :to_io, :body)
9   def close
10     body.close if body.respond_to?(:close)
11     to_io.close unless to_io.closed?
12     self.to_io = nil
13   end
14 end