MCE requiring a "major" rewrite is a strong phrase. Not all use-cases requires a "major" rewrite. Typically, changes are print to MCE->print or MCE->say. The other having to write an output iterator if wanting to preserve output order which is added code and not so much changing the original code.
MCE::Loop can wrap serial code quite nicely, only changing a few lines.
Serial code.
my @input = 100..200; foreach (@input) { print "$_\n"; };
MCE code.
use MCE::Loop max_workers => 8, chunk_size => 1; my @input = 100..200; mce_loop { MCE->print("$_\n"); } @input;
MCE::Map requires only a single line change. Replacing map with mce_map.
use MCE::Map; use Time::HiRes 'sleep'; # for simulating work my @a = mce_map { sleep rand; $_ * 1.618 } 1 .. 100; print "@a\n";
In reply to Re^2: Does anyone know about the Multi-CPU Module
by marioroy
in thread Does anyone know about the Multi-CPU Module
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |