Hi Jambo Hamon,

Enjoy your vacation. When you come back, I'd likely have MCE 1.830 (bug fixes) and MCE::Shared 1.827 released on CPAN. The OO interface for shared objects makes it possible to not worry about mutex at the application level.

use MCE::Shared; my $val = MCE::Shared->scalar(0); $val->incr(); $val->incrby(20); $val->set(40); my @pairs = ('aa'..'zz'); my $oh = MCE::Shared->ordhash(); my $ha = MCE::Shared->hash(); $oh->assign( @pairs ); $ha->assign( @pairs ); $ha->set( counter => 0 ); $ha->incr('counter'); $ha->incrby('counter', 2); my $val = $ha->get('counter'); # Scoping works similarly to lexical scoping in Perl. # The shared object is destroyed upon leaving the scope. { my $ar = MCE::Shared->array(1..9); $ar->assign('aa'..'zz'); }

Passing a code reference via IPC isn't supported at this time. Perhaps, I can add filter support for STORE (set), FETCH (get) at a later time. I'm currently at a code freeze with MCE 1.830 and MCE::Shared 1.827.

use MCE::Shared; my $obj = MCE::Shared->scalar(0); $obj->filter_store_value( \&code ); $obj->filter_fetch_value( \&code );

Regards, Mario


In reply to Re^3: Why won't this Deadlock? by marioroy
in thread Why won't this Deadlock? by Jambo Hamon

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.