Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: parallel functions

by marioroy (Chaplain)
on Nov 25, 2012 at 06:26 UTC ( #1005465=note: print w/replies, xml ) Need Help??

in reply to parallel functions

A new parallel module was recently added to CPAN called MCE. This is how one could run 2 functions in parallel using MCE.

#!/usr/bin/perl use 5.014; use MCE; my $mce = MCE->new( max_workers => 2, user_func => sub { my $self = shift; if ($self->wid == 1) { test1(); } else { test2(); } } ); $mce->run(); sub test1 { sleep 3; say "in test1"; } sub test2 { sleep 2; say "in test2"; }


in test2 in test1

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1005465]
[johngg]: Yes, must be nearly 30 years ago.
[hippo]: Loudest gig I can recall was Wolfsbane at the Astoria in the early 90s. Head rang for about 3 days afterwards. They were top, though.
[johngg]: My ears are still ringing!
Discipulus was outside The Clash concert in 1985..
[marto]: Wolfsbane , now I'm having flashbacks
[choroba]: Isn't Using PerlPod Creatively rather a meditation?
[choroba]: I don't see a question

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (13)
As of 2017-03-24 12:07 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (301 votes). Check out past polls.