Sha256: 3da5da6fcc42c87413dc598a755f235e34a0bac01249f92fae9ee301e1718469
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
module JdiHook class StreamRedirectThread < java.lang.Thread include_class "java.io.IOException" BUFFER_SIZE = 2048 PRIORITY = java.lang.Thread::MAX_PRIORITY-1 # Parameters: # name = a name for this thread for display purposes # input = java input stream # label = label for output # output = ruby output object # bufsz = read buffer size (Default: BUFFER_SIZE) # pri = thread priority (Default: PRIORITY) def initialize(name, input, label, output, bufsz=nil, pri=nil) super(name) @input = java.io.InputStreamReader.new(input) @label = label @output = output @bufsz = bufsz || BUFFER_SIZE setPriority(pri || PRIORITY) end def run() begin cbuf = Array.new(@bufsz).to_java(:char) while ((count = @input.read(cbuf, 0, @bufsz)) >= 0 ) dat = cbuf[0,count].map {|x| x.chr}.join().chomp @output.puts dat.split("\n").map {|l| "** #{@label} => #{l}"} end @output.flush() rescue IOException => exc STDERR.puts("Child I/O Transfer - #{exc}") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
emonti-jdi_hook-1.0.0 | lib/jdi_hook/stream_redirect_thread.rb |