in reply to Re: Parallel::ForkManager and multiple datasets
in thread Parallel::ForkManager and multiple datasets
I got this working, but only for a single data set.I forgot there was another foreach loop going on in one of the "dostuff" sections which is creating a multi dimensional array.
The problem becomes, how do I return a multidimensional array in its entirety back to the parent?
#pseudo code use Parallel::ForkManager; my @names = (); my %list = (); my %thing = (); $threads = 20 my $pfm = new Parallel::ForkManager( $threads ); $pfm->run_on_finish( sub { my ($pid, $exit_code, $ident, $exit_signal, $core_dump, $data_stru +cture_reference) = @_; my $name = $data_structure_reference->{name}; %list = $data_structure_reference->{data1}; $thing{$name}{a} = $data_structure_reference->{thing1}; $thing{$name}{b} = $data_structure_reference->{thing2}; push @names, $data_structure_reference->{name}; }); }); FOREACH: foreach my $thing(keys %{$things_hr}) { my $pid = $pfm->start and next; #do stuff push @names, $name; #do stuff $thing1{$name}{a} = $value1; $thing{$name}{b} = $value2; #do stuff Foreach $id:{ $list{$id}{$name}{b} = $b; $list{$id}{$name}{e} = $b1; $list{$id}{$name}{a} = 0; $list{$id}{$name}{c} = $ar->[$id][3]; $list{$id}{$name}{i} = $ar->[$id][1]; $list{$id}{$name}{j} = $ar->[$id][2]; $list{$id}{$name}{k} = sprintf("%.4f",$ar->[$id][9]); } $pfm->finish( 0, { data1 => %id, name => $sample_name, thing1 => $value1, thing2 => $value2,}); $pfm->wait_all_children;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Parallel::ForkManager and multiple datasets
by tybalt89 (Monsignor) on Jul 09, 2018 at 03:25 UTC |