in reply to threads :: shared hash of hashes (array of arrays)

One rule I follow is that shared hashes will only share their first level key by default. So you need to explicitly share, then define, all deeper keys manually. I usually do something like this, to give each thread it's own shared hash. Of course, you can get more clever coding, but this makes it clear.
my %shash; #share(%shash); #will work only for first level keys my $numworkers = 3; 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 Remember How Lucky You Are

Replies are listed 'Best First'.
Re^2: threads :: shared hash of hashes (array of arrays)
by BrowserUk (Patriarch) on Oct 18, 2008 at 13:02 UTC
      Thanks. I'll keep the note.