use MCE::Flow Sereal => 1; use Time::HiRes qw(time); my $start = time; my @queue; my @line; # same ratio - i guess 20 MP my $width = 1280 * 4; my $height = 1024 * 4; my $qsize = 32; # The bounds_only option applies to sequence of numbers # which means to compute the begin and end boundaries only, # not the numbers in between. Thus, workers receive 2 # numbers in @{ $chunk_ref }. MCE::Flow::init( max_workers => 'auto', chunk_size => 16, bounds_only => 1, gather => sub { my (@ret) = @_; } ); # Same as mce_flow_s sub { ... }, 0, $width - 1; MCE::Flow::run_seq( sub { my ($mce, $chunk_ref, $chunk_id) = @_; for my $x ( $chunk_ref->[0] .. $chunk_ref->[1] ) { for my $y ( 0 .. $height - 1 ) { my $coords = [ $x, $y ]; push @line, $coords; if ( scalar @line == $width ) { push @queue, [@line]; @line = (); # audacious actions start here if ( scalar @queue == $qsize ) { my @ret; # save output to @ret ?? # dd \@queue; MCE->gather(@ret); @queue = (); } } } } }, 0, $width - 1 ); printf "Took %.3f seconds\n", time - $start;