Seeking some threads wisdom, or at least a special dispensation...

As the doco's say, thread shared objects can't be blessed. And only scalars can be passed on Thread::Queues.

I've got a multithreaded server architecture (sortof a publish/subscribe, or perhaps observer/observable pattern). A request comes in, I turn it into a perl object, then have to give multiple configurable modules a chance to fiddle with it, possibly with long latency operations. When they're all done fiddling, the resulting request object gets marshalled and forwarded out the backend.

Problem is, I need a way to post the request object to the fiddler modules so they can each play their tune, and the request object just waits til everyone finishes.

Since I can't share the blessed object with the fiddler threads, the only thing I can think of is to somehow marshall the interesting bits out of the request object into a shared hash, and have each fiddler thread create a "shadow" request object to provide fiddling methods, then send it all back up to the original request object again. (Slow, painful, very likely error prone).

Can anyone recommend an alternative method/pattern to accomplish this (aside from jumping to Javayukfoo) ?


In reply to Passing objects between threads...any solutions ? by kimanaw

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.