Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: sharing a hash of hashes between threads

by spurperl (Priest)
on Jun 22, 2005 at 05:45 UTC ( [id://468915]=note: print w/replies, xml ) Need Help??


in reply to sharing a hash of hashes between threads

The solution proposed the sage BrowserUk looks good, but you can see that it's not entirely trivial to declare inner subhashes as shared. Moreover, the solution will be only become more and more complex the deeper your structure gets.

Maybe you can solve your problem by simplifying the specification ? Use Thread::Queue (it works great with "threads") to pass data between threads. On the receiving side, first shove the data into the hash and then print/process it.

This way, you also don't expose the internal representation of the processing thread to the receiving thread, thus keeping the interface cleaner and more flexible.

Replies are listed 'Best First'.
Re^2: sharing a hash of hashes between threads
by coontie (Sexton) on Jun 22, 2005 at 13:39 UTC
    Thank you! I went back to threads:q. Sticking a hash onto the queue triggered an error msg from within Threads/Queue.pm. What I did instead, is to enqueue the raw data string and then I split it/hash it in main. That works perfectly! Thank you all for you help!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://468915]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-03-29 00:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found