threads::shared::tie does not play nice with Storable. The solution is to make a copy of the hash before writing it to disk:
#! perl -slw
use strict;
use threads;
use threads::shared;
use Storable qw[ nstore retrieve ];
use Data::Dump qw[ pp ];
my %hash :shared = (
a=>1,
b=>1,
);
async {
nstore { %hash }, 'fred.bin';
}->join;
my $hash2 = retrieve 'fred.bin';
pp $hash2;
__END__
C:\test>junk42
{ a => 1, b => 1 }
That does mean you'll have to share_clone() it if you need it shared once you retrieve() it.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
|