1 # -*- encoding: binary -*-
4 # Used to keep track of file offsets in IO#trysendfile + 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
10 attr_accessor :offset, :count
12 def initialize(offset, count, io, body)
13 @offset, @count, @to_io, @body = offset, count, io, body
17 @body.close if @body.respond_to?(:close)
18 @to_io.close unless @to_io.closed?