Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Guys,
{A}{1}{C} = 1
{A}{1}{D} = 2
.
.
{B}{1}{C} = 3
{B}{1}{D} = 4
Later in a thread I want to do a deep copy of a given record eg
I'm trying to copy hash record structures from a global shared hash to a local copy, so the threads won't have to lock the global all the time.
Basically I have
with data like this:{ package cfg; %cfg::sessions = (); threads::shared::share(%cfg::sessions); }
{A}{1}{C} = 1
{A}{1}{D} = 2
.
.
{B}{1}{C} = 3
{B}{1}{D} = 4
Later in a thread I want to do a deep copy of a given record eg
I've tried eg$myhash{A} = $cfg::sessions{A};
but get 'Not a reference value' error.use Storable qw(dclone); $myhash{A} = dclone($cfg::sessions{A});
I tried
but get a 'Segementation violation'.use Clone qw(clone); $myhash{A} = clone($cfg::sessions{A});
In a simple (non-thread) test prog, both of the above work perfectly.
Is it possible to make these work under threads, or should I write my own fn?
Cheers
Chris
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Using clone/dclone with threads
by BrowserUk (Patriarch) on Nov 22, 2004 at 07:21 UTC | |
Re: Using clone/dclone with threads
by castaway (Parson) on Nov 22, 2004 at 06:09 UTC | |
by Anonymous Monk on Nov 23, 2004 at 23:11 UTC | |
Re: Using clone/dclone with threads
by exussum0 (Vicar) on Nov 23, 2004 at 12:12 UTC | |
by BrowserUk (Patriarch) on Nov 23, 2004 at 13:45 UTC | |
Re: Using clone/dclone with threads
by Anonymous Monk on Nov 23, 2004 at 23:05 UTC | |
by Anonymous Monk on Nov 23, 2004 at 23:50 UTC | |
Re: Using clone/dclone with threads
by Anonymous Monk on Sep 20, 2011 at 18:14 UTC |
Back to
Seekers of Perl Wisdom