Sha256: f77d652e295e7e5c281b98d62906254b4a4c94a82399e135e8f7468a5df5f28f
Contents?: true
Size: 937 Bytes
Versions: 7
Compression:
Stored size: 937 Bytes
Contents
module ChildProcess module JRuby class Pump BUFFER_SIZE = 2048 def initialize(input, output) @input = input @output = output @stop = false end def stop @stop = true @thread && @thread.join end def run @thread = Thread.new { pump } self end private def pump buffer = Java.byte[BUFFER_SIZE].new until @stop read, avail = 0, 0 while read != -1 avail = [@input.available, 1].max read = @input.read(buffer, 0, avail) if read > 0 @output.write(buffer, 0, read) @output.flush end end sleep 0.1 end @output.flush rescue java.io.IOException => ex $stderr.puts ex.message, ex.backtrace if $DEBUG end end # Pump end # JRuby end # ChildProcess
Version data entries
7 entries across 7 versions & 1 rubygems