I'm trying redirect the standard output into another variable, here a
GtkTextBuffer, but it's pretty slow for
a reason I don't understand. I don't fully understand tasks so maybe
there's a scope or compilation problem, I don't know.
Using @time is particularly bad for some reason, it take about two second
to complete.
Inserting into a buffer is fast by the way, even if it's a global variable.
Any hints?
using Gtk
function redirect()
buffer = @GtkTextBuffer()
function print_std_out(rd::Base.PipeEndpoint,buffer::GtkTextBuffer)
response = readavailable(rd)
if !isempty(response)
insert!(buffer,bytestring(response))
end
end
stdout_task = @schedule begin
rd, wr = redirect_stdout()
while(true)
print_std_out(rd,buffer)
end
end
end
redirect()
@time 1