Hello marioroy,

Thanks for the warning. Luckily I didn't run into this problem since I started to build on one of your examples using the shorthand tie my %test, 'MCE::Shared' ;

The sharing mechanism actually works all very well using the above statement causing me quite some problems because I did something rather dull. In this example below I successfully managed to destroyed the original hash $h because I didn't realize the consequence of the nested reference (LOL):

use strict ; use warnings ; use MCE::Shared ; use Data::Dumper ; my $h = { L1_counter => 1, nested1 => { L2_counter => 1, nested2 => { L3_counter => 1, }, }, } ; my @dupkeys = qw{ nested1 } ; tie my %result, 'MCE::Shared' ; @result{@dupkeys} = @{$h}{@dupkeys} ; # Whoops! print Dumper( $h ) ; __END__ $VAR1 = { 'nested1' => { 'L2_counter' => 1, 'nested2' => bless( [ 3, 'MCE::Shared::Hash' ], 'MCE::Shared::Object' ) }, 'L1_counter' => 1 };

Don't worry too much about whatever I am trying. I am still in the process of understanding the MCE library and for me this is all a big learning exercise for personal development/hobby and all your help is greatly appreciated.

Couple of other things that I ran into during my endeavors are MCE::Hobo->pending();. It returns 0 when called inside a async block. Is there another way to get the number of pending threads?

Another thing I was wondering about, if it is possible to create an hash/object and transfer the control to the mother process (without using the sharing mechanism). This would be useful if the object can be created autonomously by a worker process and cut out the extra overhead needed for sharing. Especially if this could be done by passing a reference. (Maybe $mce->gather)?

Thanks,
Veltro


In reply to Re^2: Hobo with a bit of recursion by Veltro
in thread Hobo with a bit of recursion by Veltro

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.