I had a poke at shared objects a little while ago.

You can share an arbitrarily complicated structure, with refs to arrays, hashes and scalars, to any depth you like. The tricky bit, I found, was that with refs to shared arrays and hashes you have to create an empty anonymous array/hash, mark it shared and then populate it.

With objects the problem was that this meant that the object maker had to know to construct a shared object.

As you say, the late model threads::shared claims:

shared_clone REF

shared_clone takes a reference, and returns a shared version of its argument, preforming (sic) a deep copy ...

so, an object can be made shared after the event, now. But of the class adds new hashes or arrays to the object, without knowing they too need to be made shared, "fun" will ensue -- sure as eggs is eggs and this is not a pipe (also, no spoon). Not to mention the small issue of managing shared access to the object components.

I'd be interested to hear how that goes !


In reply to Re^2: shared complex scalars between threads by gone2015
in thread shared complex scalars between threads by Anonymous Monk

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.