in reply to Re^2: Wanting some clarification / opinions on MCE vs Threads
in thread Wanting some clarification / opinions on MCE vs Threads

(I should say my threads equivalent)

Hm. No offence but, Ew! :)

Remember that MCE is a wrapper (actually a suite of wrappers, or is that sweet wrapper:) over the top of threads(and other things), providing syntactic sugar for simple operations.

You can easily do the same yourself. Say write TGrep.pm:

Then write:

#! perl -slw use strict; use TGrep; use Time::HiRes qw[ time ]; our $N //= 1e3; my $start = time; my @a = tgrep{ $_ % 5 == 0 } [ 1..$N ]; printf "Took %.9f seconds\n", time() -$start; print scalar @a; __END__ C:\test>t-tgrep -N=1e5 Took 3.830074787 seconds 20000

Of course, you'd probably be better sticking to grep for such simple things:

$t=time; my @a = grep{ $_%5 == 0 } 1 .. 1e6; print time-$t;; 0.18144702911377

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked
? @{ $_ } : $_ } @_ ); $Qin-

Replies are listed 'Best First'.
Re^4: Wanting some clarification / opinions on MCE vs Threads
by jmmitc06 (Beadle) on Feb 05, 2015 at 14:50 UTC

    Yeah, I would never use threads for something this simple, I was just demonstrating what I perceived to be a readability improvement between threads and MCE with that example since it was quick to work up.

    Since it is just a wrapper for threads, does it make sense to use it in when possible? Is there any reason not to use it IF I am in a situation where I can install modules? (which I should be since 99% of the time I'm running code on my lab machines). I'm starting to think that there isn't a downside except that MCE is not part of a standard Perl install but there aren't many code examples of MCE in the wild so it's hard to tell.

      Since it is just a wrapper for threads,

      It seems to do more than just wrap threads. Indeed, it appears to spawn processes by default and only uses threads if you ask for them.

      does it make sense to use it in when possible?

      If you're (more) comfortable using this kind of (IMO over-engineered) framework, then take a look at the bug history (short & up to date) and maintenance history (3 new versions in 3 months) and then try it for your application.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
      In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked
        Ignore this one too X_X
      nm, I understand now
Re^4: Wanting some clarification / opinions on MCE vs Threads
by karlgoethebier (Abbot) on Feb 07, 2015 at 13:40 UTC
    use Threads::Queue;

    I just wondered why i failed to install Threads::Queue ;-)

    Perhaps i should have better read the code: my( $Qin, $Qout ) = map Thread::Queue->new, 1..2;?

    My best regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

      I just wondered why i failed to install Threads::Queue ;-)

      Whoops! Sorry about that. (Now corrected; thanks.)


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
      In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked