Hi zentara.

The sharing aspect is done through shared socket handles constructed using socketpair.

MCE::Shared::Server spawns a manager process. On the Windows platform or when threads is present; e.g. use threads, a thread is spawned instead. The data is managed by the shared-manager where it resides. MCE::Shared::Server is a two-part module. Shared objects are MCE::Shared::Object, the client facing package containing AUTOLOAD.

A shared object is a blessed array reference containing ID and CLASS_NAME. To see the actual data, one must call export.

use strict; use warnings; use feature 'say'; use MCE::Shared; use Data::Dumper; # first time, spawns the MCE::Shared::Server manager my $va1 = MCE::Shared->scalar('foo'); my $ar1 = MCE::Shared->array('a'..'c'); my $ha1 = MCE::Shared->hash('foo' => 'bar'); say Dumper $ha1; say Dumper $ha1->export; # construction via the TIE interface my $va2 = tie my $va, 'MCE::Shared', 'foo'; my $ar2 = tie my @ar, 'MCE::Shared', 'a'..'c'; my $ha2 = tie my %ha, 'MCE::Shared', 'foo' => 'bar'; say Dumper $ha2; say Dumper $ha2->export; # or Dumper tied(%ha)->export; __END__ $VAR1 = bless( [ 3, 'MCE::Shared::Hash' ], 'MCE::Shared::Object' ); $VAR1 = bless( { 'foo' => 'bar' }, 'MCE::Shared::Hash' ); $VAR1 = bless( [ 6, 'MCE::Shared::Hash' ], 'MCE::Shared::Object' ); $VAR1 = bless( { 'foo' => 'bar' }, 'MCE::Shared::Hash' );

The upcoming 1.825 release can return an unblessed array or hash for later converting to JSON. From receiving the idea from 1nickt. Thank you.

say Dumper $ha2->export({ unbless => 1 }); $VAR1 = { 'foo' => 'bar' };


In reply to Re^4: how to fork & join in tk? by marioroy
in thread how to fork & join in tk? by redss

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.