lib/dtas/pipe.rb in dtas-0.15.0 vs lib/dtas/pipe.rb in dtas-0.16.0

- old
+ new

@@ -1,10 +1,10 @@ -# Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org> +# Copyright (C) 2013-2019 all contributors <dtas-all@nongnu.org> # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt> # frozen_string_literal: true begin - require 'io/splice' + require 'sleepy_penguin' rescue LoadError end require_relative '../dtas' require_relative 'writable_iter' require_relative 'nonblock' @@ -18,14 +18,17 @@ _, w = rv = pipe w.writable_iter_init rv end - # create no-op methods for non-Linux - unless method_defined?(:pipe_size=) - def pipe_size=(_) - end + def pipe_size=(nr) + defined?(SleepyPenguin::F_SETPIPE_SZ) and + fcntl(SleepyPenguin::F_SETPIPE_SZ, nr) end + + def pipe_size + fcntl(SleepyPenguin::F_GETPIPE_SZ) + end if defined?(SleepyPenguin::F_GETPIPE_SZ) # avoid syscall, we never change IO#nonblock= directly def nonblock? false end