Hi zentara,

For MCE::Shared, the use of IO::FDPass applies to Condvar, Queue and to mce_open when constructing a shared handle from a non-shared handle not yet knowed to the shared-manager process. IO::FDpass isn't used for anything else.

use MCE::Shared; # starting the shared-manager, implicitly my $ca = MCE::Shared->cache( max_keys => 500 ); # or starting early, explicitly MCE::Shared->start(); # at this point, IO::FDPass is necessary for constructing # a shared condvar or queue, passing fd descriptor # ... for new socket handle made during construction # workers block using a socket handle for ->wait, ->timedwait # the shared-manager unblocks by writing to _cw_sock my $cv = MCE::Shared->condvar(); # _cw_sock # ... for new socket handles made during construction # workers block using socket handles for ->dequeue, ->await # the shared-manager unblocks by writing to _qw_sock, _aw_sock my $q1 = MCE::Shared->queue(); # _qw_sock my $q2 = MCE::Shared->queue( await => 1 ); # _aw_sock

Without IO::FDPass, one cannot construct a shared condvar or queue while the shared manager is running. The work around is to construct these before other shared objects (e.g. ->array, ->hash, etc). Then, start the shared-manager manually.

use MCE::Shared; my $cv = MCE::Shared->condvar(0); my $que = MCE::Shared->queue( fast => 1 ); MCE::Shared->start() # must start manually my $hash = MCE::Shared->hash(); # or implicitly

Note: MCE starts the shared-manager if not started. Ditto for MCE::Hobo because that constructs two shared hashes.

Regarding mce_open, IO::FDPass is needed when constructing a shared-handle from a non-shared handle not yet available inside the shared-manager process. The workaround is having the non-shared handle made before the shared-manager process is started implicitly or explicitly.

# the shared-manager knows of \*STDIN, \*STDOUT, \*STDERR mce_open my $shared_in, "<", \*STDIN; # ok mce_open my $shared_out, ">>", \*STDOUT; # ok mce_open my $shared_err, ">>", \*STDERR; # ok # but may not know of $non_shared_fh mce_open my $shared_fh, ">>", $non_shared_fh;

Regards, Mario


In reply to Re^5: Prima + MCE::Hobo demonstration by marioroy
in thread Prima + MCE::Hobo demonstration 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.