Greetings perlygapes,

Here is a version using MCE::Hobo. Workers may exit gracefully on Unix platforms to ease non-thread safe module(s) and possibly dependencies. Internally, MCE::Hobo sets the base generator uniquely between workers. Also for Math::Prime::Util and Math::Random.

#!/usr/bin/perl use 5.24.0; # Book, Chapter and Verse use strict; # the First Commandment use warnings; # the Second Commandment use Digest::MD5 qw(md5_hex); # identity and volition use Math::Prime::Util ':all'; # the Tempter # provides 'todigitstring' and 'fromdigits' use MCE::Hobo; # the Family Unit my @children = ("Cain","Abel","Seth","Noah","Shem"); my $children = 5; my $birthorder = 0; # Set max_workers to limit # of workers running simultaneously. # Set posix_exit to avoid all END and destructor processing # inside the worker (ignored on the Windows platform). MCE::Hobo->init( max_workers => $children, posix_exit => 1 ); the_main_reason(); sub the_main_reason { printf "Forming $children children.\n"; foreach my $child (@children) { $birthorder++; print "Today, I have begotten child $birthorder as $child\n"; MCE::Hobo->create("begotten_child", $child) } # my longsuffering print "Waiting on begotten childen...\n"; MCE::Hobo->waitall(); } # the_main_reason sub begotten_child { my ($child) = @_; if ($child =~ m/cain/i) { the_task_I_gave_cain_to_do("Cain"); } elsif ($child =~ m/abel/i) { the_task_I_gave_abel_to_do("Abel"); } elsif ($child =~ m/seth/i) { the_task_I_gave_seth_to_do("Seth"); } elsif ($child =~ m/noah/i) { the_task_I_gave_noah_to_do("Noah"); } elsif ($child =~ m/shem/i) { the_task_I_gave_shem_to_do("Shem"); } # enable some prayer print "Child $child exiting\n"; MCE::Hobo->exit(0); } # begotten_child exit; ...

Regards, Mario


In reply to Re: Parallel::ForkManager dies with "Free to wrong pool..." by marioroy
in thread Parallel::ForkManager dies with "Free to wrong pool..." by perlygapes

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.