initial
[ruby_io_splice.git] / lib / io / splice.rb
bloba19398188c4a4c7e60662c56d80e5e4df54f941b
1 # -*- encoding: binary -*-
2 require 'io_splice_ext'
4 class IO
6   class Splice
8     # the version of IO::Splice, currently 0.1.0
9     VERSION = '0.1.0'
11     # The maximum capacity of the pipe in bytes.
12     # Under stock Linux, this is 65536 bytes as of 2.6.11, and 4096 before
13     # We detect this at runtime as it is easy to recompile the kernel
14     # and set a new value.
15     PIPE_CAPA = begin
16       rd, wr = IO.pipe
17       buf = ' ' * PIPE_BUF
18       n = 0
19       begin
20         n += wr.write_nonblock(buf)
21       rescue Errno::EAGAIN
22         break
23       end while true
24       wr.close
25       rd.close
26       n
27     end
29   end
30 end