rainbows.git  about / heads / tags
Unicorn for sleepy apps and slow clients
blob 11c84d465cfe19043439df4b67a024e65064d418 524 bytes (raw)
$ git show v0.97.0:lib/rainbows/stream_file.rb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
 
# -*- encoding: binary -*-
# :enddoc:

# Used to keep track of file offsets in IO#sendfile_nonblock + evented
# models.  We always maintain our own file offsets in userspace because
# because sendfile() implementations offer pread()-like idempotency for
# concurrency (multiple clients can read the same underlying file handle).
class Rainbows::StreamFile < Struct.new(:offset, :count, :to_io, :body)
  def close
    body.close if body.respond_to?(:close)
    to_io.close unless to_io.closed?
    self.to_io = nil
  end
end

git clone https://yhbt.net/rainbows.git