threads::shared seems only serve for simple array, scalar or hash.
Look again at threads::shared::shared_close(). Eg:
use threads;;
use threads::shared;
my @r = ( map+{ map{ $_ => [ 1 .. 10 ] } 'a' .. 'z' }, 1..10 );;
pp \@r;;
[
{
a => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
b => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
c => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
d => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
e => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
f => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
g => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
h => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
i => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
j => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
k => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
l => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
"m" => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
n => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
o => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
p => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
"q" => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
r => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
"s" => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
t => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
u => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
v => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
w => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
"x" => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
"y" => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
z => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
},
{
a => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
...
},
]
my @s : shared = map shared_clone( $_ ), @r;
pp \@s;
[
# tied threads::shared::tie
{
# tied threads::shared::tie
a => [ # tied threads::shared::tie
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
],
b => [ # tied threads::shared::tie
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
],
c => [ # tied threads::shared::tie
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
],
d => [ # tied threads::shared::tie
...
],
...
},
{
# tied threads::shared::tie
a => [
# tied threads::shared::tie
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
],
b => ...
}
...
]
It won't clone subroutines, because that's not possible or logical.
However, whilst this allows you to share complex data structures, you'll generally find that it doesn't achieve what you think you want to achieve, and you'll probably come back asking why not.
If you would describe your application, there is usually a better way of achieving it.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Outside of code tags, you may need to use entities for some characters:
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.