Wonderful! you monks move so fast!

I think I still have some questions, but must digress into context to motivate them

My concept is to pipeline some data through several threads, passing data between threads via queues. I wish to put a reference to an anonymous hash on the first queue, then have the first thread take it off, read it's values, create one or more anonymous hashes and pass them on to the next queue.

The original hash does not get changed by the thread, though it's keys and values will get copied to all the new hashes created by the thread (for this iteration of the while

my $inqueueref = shift; my $outqueueref = shift; my %inhash; while (%inhash = $inqueueref->dequeue) { #create one or more new anonymous hashes and $outqueue->enqueue(\%ou +thash) }

).

Note that the relationship between the number of %inhashes and %outhashes is one:many.

Note that any given hash is only shared by two threads; the one creating it and the next one (reading it).

Now here's the follow-on question: How does the above solution using threads::shared change when the hashes are all anonymous hashes?

or do I need some monster "global array of hashes" package whith lots of thread-safe methods encapsulating it and protecting it from direct access by all these threads (possibly putting the array index on the queues in this implementation)? I sure hope not.


In reply to Re: scalars, references and queues by Anonymous Monk
in thread scalars, references and queues 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.