From: howa on
Sometimes, I want to take the advantage of multi-core processor, and
make the full use of my CPU time,

e.g. I have a function, which takes a file name as input, do some text
processing (e.g. CPU intensive), and save it back.

I don't want to use thread, as it need to recompile perl on all my
machines and I am not sure if it is stable enough to affect other
apps.

I don't mind to have a little overhead in using the fork mode (i.e.
multi-process). I want to know are there any recommended module for
my purpose?

For example, I am trying Parallel::ForkManager, POE::Wheel::Run, so
anyone want to share the experiences?


Thanks.
From: Peter Makholm on
howa <howachen(a)gmail.com> writes:

> For example, I am trying Parallel::ForkManager, POE::Wheel::Run, so
> anyone want to share the experiences?

I have used Parallel::ForkManager a lot with no problems, it just
works. I have never had the need to communicate enything more complex
than the exit code back to the parrent though.

//Makholm
From: nolo contendere on
On Apr 16, 4:50 am, Peter Makholm <pe...(a)makholm.net> wrote:
> howa <howac...(a)gmail.com> writes:
> > For example, I am trying Parallel::ForkManager, POE::Wheel::Run, so
> > anyone want to share the experiences?
>
> I have used Parallel::ForkManager a lot with no problems, it just
> works. I have never had the need to communicate enything more complex
> than the exit code back to the parrent though.

I've found it useful to pass an $ident which i can use in the
run_on_finish callback to associate with the exit code.
From: Peter Makholm on
nolo contendere <simon.chao(a)fmr.com> writes:

>> I have used Parallel::ForkManager a lot with no problems, it just
>> works. I have never had the need to communicate enything more complex
>> than the exit code back to the parrent though.
>
> I've found it useful to pass an $ident which i can use in the
> run_on_finish callback to associate with the exit code.

Yes, but I consider this to be communication from the parrent on fork
time to the parrent on wait time. Even if the $ident is an reference
to something, the child can't change it for the parrent.

//Makholm
From: nolo contendere on
On Apr 16, 11:10 am, Peter Makholm <pe...(a)makholm.net> wrote:
> nolo contendere <simon.c...(a)fmr.com> writes:
> >> I have used Parallel::ForkManager a lot with no problems, it just
> >> works. I have never had the need to communicate enything more complex
> >> than the exit code back to the parrent though.
>
> > I've found it useful to pass an $ident which i can use in the
> > run_on_finish callback to associate with the exit code.
>
> Yes, but I consider this to be communication from the parrent on fork
> time to the parrent on wait time. Even if the $ident is an reference
> to something, the child can't change it for the parrent.
>

True, perhaps I should have replied to the OP. I was simply sharing my
experience with Parallel::ForkManager, didn't mean to imply that the
$ident was a child->parent communication.