This is probably simpler advice, than the file gurus have given you, but here goes.....

If you are filling your ram after a few runs, you are not running the threads properly. Crashes shouldn't happen if joined properly, but you may need to reuse your threads.

Although it is probably the same idea as IO::AIO , you could open multiple pipes for writing with opens. This is untested, but should open 7 fh's in parallel. If you can get this to work, then you can integrate it into a Gtk2 program, with a single thread. 7 fh's will probably be faster that 7 threads, because the 7-threaded process will all share the same execution pointer since they are in the same pid. If you integrate it into Gtk2, you can setup Glib::IO->add_watch (fileno $fh, qw/out/, \&watch_callback, $fh); to watch for errors and completion of the writes. But if I were you, I would get it working from the commandline first, before adding gui complexities.

It may be that to improve writing speed to each filehandle, you may need to spawn a piped open to the filelocation, and "cat the_file" to each location. That would relieve your Gtk2 app from the actual copying, by handing it off to cat. So instead of writing to the filhandles, you could fork and exec 7 times and exec "cat $infile > $outfile".

#!/usr/bin/perl use warnings; use strict; my $infile = shift || $0; my %pids; for(1..7){ $pid{$_}{'pid'} = open( "$pid{$_}{'FH'} > $pid{$_}{'file_location'}" +) or warn "$!\n"; } open( IF,"< $infile" ) or die "$!\n"; while (<IF>){ my $line = $_; for(1..7){ print $pid{$_}{'FH'}, $line; } } print "done\n"; for(1..7){ close $pid{$_}{'FH'}; }

I'm not really a human, but I play one on earth. Cogito ergo sum a bum

In reply to Re: Gtk2 w/ concurrent tasks by zentara
in thread Gtk2 w/ concurrent tasks by thezog

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.