1 # The goal of this is to use a synthetic (non-IO) reader
2 # to trigger the read/write loop of IO.copy_stream,
3 # bypassing in-kernel mechanisms like sendfile for zero copy,
4 # so we wrap the /dev/zero IO object:
9 @in = File.open('/dev/zero', 'rb')
13 return if (@n -= 1) == 0
20 dst = File.open(IO::NULL, 'wb')
21 n = IO.copy_stream(src, dst)
24 end if IO.respond_to?(:copy_stream) && IO.const_defined?(:NULL)