in reply to Gtk2 w/ concurrent tasks
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'}; }
|
|---|