about summary refs log tree commit homepage
path: root/lib/rainbows/stream_file.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rainbows/stream_file.rb')
-rw-r--r--lib/rainbows/stream_file.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/rainbows/stream_file.rb b/lib/rainbows/stream_file.rb
new file mode 100644
index 0000000..f533f18
--- /dev/null
+++ b/lib/rainbows/stream_file.rb
@@ -0,0 +1,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, :to_io)
+
+  def close
+    to_io.close
+    self.to_io = nil
+  end
+end