Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Sharing multitiered hash amongst multiple threads?

by zentara (Archbishop)
on Jan 28, 2006 at 21:04 UTC ( #526212=note: print w/replies, xml ) Need Help??

in reply to Sharing multitiered hash amongst multiple threads?

When you declare a hash as shared that way, it only works for the first level keys. You need to specifically declare each level as shared. Like this. I always do it manually, but you could setup some sort of loop to declare your deep levels. Remember, you need to declare them as shared before you assign a value.
foreach my $dthread(1..$numworkers){ share ($shash{$dthread}{'go'}); share ($shash{$dthread}{'progress'}); share ($shash{$dthread}{'timekey'}); #actual instance of the thread share ($shash{$dthread}{'frame_open'}); #open or close the frame share ($shash{$dthread}{'handle'}); share ($shash{$dthread}{'data'}); share ($shash{$dthread}{'pid'}); share ($shash{$dthread}{'die'}); $shash{$dthread}{'go'} = 0; $shash{$dthread}{'progress'} = 0; $shash{$dthread}{'timekey'} = 0; $shash{$dthread}{'frame_open'} = 0; $shash{$dthread}{'handle'} = 0; $shash{$dthread}{'data'} = $data; $shash{$dthread}{'pid'} = -1; $shash{$dthread}{'die'} = 0; $hash{$dthread}{'thread'} = threads->new(\&work,$dthread); }

I'm not really a human, but I play one on earth. flash japh

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (1)
As of 2021-10-28 01:23 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (95 votes). Check out past polls.