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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |