From: Jerry D. Hedden Date: Tue, 25 Nov 2008 11:52:12 +0000 (-0500) Subject: threads::shared 1.27 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2e58fc35b9246b8e4af62c2038aca4ea0312f6d8;p=p5sagit%2Fp5-mst-13.2.git threads::shared 1.27 From: "Jerry D. Hedden" Message-ID: <1ff86f510811250852r17a88593h373ca49c74ea0ffa@mail.gmail.com> Date: Tue, 25 Nov 2008 11:52:12 -0500 p4raw-id: //depot/perl@34915 --- diff --git a/ext/threads/shared/Makefile.PL b/ext/threads/shared/Makefile.PL index 13e8f44..2626ad6 100755 --- a/ext/threads/shared/Makefile.PL +++ b/ext/threads/shared/Makefile.PL @@ -66,6 +66,7 @@ if (grep { $_ eq 'PERL_CORE=1' } @ARGV) { 'Carp' => 0, 'XSLoader' => 0, 'Scalar::Util' => 0, + 'threads' => 1.71, 'Test' => 0, 'Test::More' => 0, diff --git a/ext/threads/shared/shared.pm b/ext/threads/shared/shared.pm index f96a59f..1409a1c 100644 --- a/ext/threads/shared/shared.pm +++ b/ext/threads/shared/shared.pm @@ -7,7 +7,7 @@ use warnings; use Scalar::Util qw(reftype refaddr blessed); -our $VERSION = '1.26'; +our $VERSION = '1.27'; my $XS_VERSION = $VERSION; $VERSION = eval $VERSION; @@ -187,7 +187,7 @@ threads::shared - Perl extension for sharing data structures between threads =head1 VERSION -This document describes threads::shared version 1.26 +This document describes threads::shared version 1.27 =head1 SYNOPSIS @@ -294,7 +294,7 @@ refs of shared data (discussed in next section): =item shared_clone REF C takes a reference, and returns a shared version of its -argument, preforming a deep copy on any non-shared elements. Any shared +argument, performing a deep copy on any non-shared elements. Any shared elements in the argument are used as is (i.e., they are not cloned). my $cpy = shared_clone({'foo' => [qw/foo bar baz/]}); @@ -308,8 +308,8 @@ Object status (i.e., the class an object is blessed into) is also cloned. For cloning empty array or hash refs, the following may also be used: - $var = &share([]); # Same as $var = share_clone([]); - $var = &share({}); # Same as $var = share_clone({}); + $var = &share([]); # Same as $var = shared_clone([]); + $var = &share({}); # Same as $var = shared_clone({}); =item is_shared VARIABLE @@ -532,6 +532,28 @@ circular references). Use L, instead: # The refs are equivalent } +L does not work properly on shared references +embedded in shared structures. For example: + + my %foo :shared; + $foo{'bar'} = shared_clone({'a'=>'x', 'b'=>'y', 'c'=>'z'}); + + while (my ($key, $val) = each(%{$foo{'bar'}})) { + ... + } + +Either of the following will work instead: + + my $ref = $foo{'bar'}; + while (my ($key, $val) = each(%{$ref})) { + ... + } + + foreach my $key (keys(%{$foo{'bar'}})) { + my $val = $foo{'bar'}{$key}; + ... + } + View existing bug reports at, and submit any new bugs, problems, patches, etc. to: L @@ -541,7 +563,7 @@ L Discussion Forum on CPAN: L Annotated POD for L: -L +L Source repository: L diff --git a/ext/threads/shared/t/waithires.t b/ext/threads/shared/t/waithires.t index 173d32e..4cda602 100644 --- a/ext/threads/shared/t/waithires.t +++ b/ext/threads/shared/t/waithires.t @@ -18,11 +18,9 @@ BEGIN { Test::skip_all(q/Perl not compiled with 'useithreads'/); } - eval { - require Time::HiRes; - Time::HiRes->import('time'); - }; - Test::skip_all('Time::HiRes not available') if ($@); + if (! eval 'use Time::HiRes "time"; 1') { + Test::skip_all('Time::HiRes not available'); + } } use ExtUtils::testlib;