I completed usability testing,... The following is a demonstration running MCE in the foreground and background. The spawn keyword is also used for spinning a child process per each element.

use MCE::Simple -strict, ( spawn_limit => 2, # MCE::Child processes max_workers => 2, # number of MCE workers init_relay => 1, # define to enable MCE::relay ); # Run MCE in the foreground. mce_foreach my $i (10..18) { MCE::relay { # output orderly say "$$: $i"; }; } # Run MCE in the background. spawn sub { mce_foreach my $i (20..28) { MCE::relay { say "$$: $i"; }; } }; sync; # Spin a worker per each input element. # Up to "spawn_limit" will run simultaneously. # Blocking otherwise, until next availability. spawn my $i (30..38) { say "$$: $i"; } sync;

output:

60264: 10 # alternating PIDs 60265: 11 # two MCE workers 60264: 12 60265: 13 60264: 14 60265: 15 60264: 16 60265: 17 60264: 18 60267: 20 # alternating PIDs 60268: 21 # two MCE workers 60267: 22 60268: 23 60267: 24 60268: 25 60267: 26 60268: 27 60267: 28 60269: 30 # spawn keyword 60270: 31 # unique PIDs 60271: 32 60272: 33 60273: 34 60274: 35 60275: 36 60276: 37 60277: 38

spawn keyword:

spawn my $i (30..38) { say "$$: $i"; } # filtered/transposed to this, without altering line no. foreach my $i (30..38) { MCE::Simple::_spawn_a('', sub { say "$$: $i"; }); }

In reply to Re: Code brewing for the upcoming MCE 10 year anniversary by marioroy
in thread Code brewing for the upcoming MCE 10 year anniversary by marioroy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.