diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-07-07 08:30:22 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-07-08 07:58:59 +0000 |
commit | 13baf8bd44683a376b79c01c3abbaa71e5b86a71 (patch) | |
tree | 13f7b00b6d0fa1093b9c8b3796150750929eda5b /lib/rainbows/stream_file.rb | |
parent | 9ce364b079efdb3bcef504a84e2460a9b2b4b9ad (diff) | |
download | rainbows-13baf8bd44683a376b79c01c3abbaa71e5b86a71.tar.gz |
Other concurrency models will eventually be able to use it, too.
Diffstat (limited to 'lib/rainbows/stream_file.rb')
-rw-r--r-- | lib/rainbows/stream_file.rb | 14 |
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 |