Fix up .gitignore files some more
[p5sagit/p5-mst-13.2.git] / ext / threads / shared / shared.pm
index fee9365..1409a1c 100644 (file)
@@ -7,7 +7,7 @@ use warnings;
 
 use Scalar::Util qw(reftype refaddr blessed);
 
-our $VERSION = '1.21';
+our $VERSION = '1.27';
 my $XS_VERSION = $VERSION;
 $VERSION = eval $VERSION;
 
@@ -133,10 +133,6 @@ $make_shared = sub {
     elsif ($ref_type eq 'SCALAR') {
         $copy = \do{ my $scalar = $$item; };
         share($copy);
-        # Clone READONLY flag
-        if (Internals::SvREADONLY($$item)) {
-            Internals::SvREADONLY($$copy, 1);
-        }
         # Add to clone checking hash
         $cloned->{$addr} = $copy;
     }
@@ -169,8 +165,13 @@ $make_shared = sub {
     }
 
     # Clone READONLY flag
+    if ($ref_type eq 'SCALAR') {
+        if (Internals::SvREADONLY($$item)) {
+            Internals::SvREADONLY($$copy, 1) if ($] >= 5.008003);
+        }
+    }
     if (Internals::SvREADONLY($item)) {
-        Internals::SvREADONLY($copy, 1);
+        Internals::SvREADONLY($copy, 1) if ($] >= 5.008003);
     }
 
     return $copy;
@@ -186,7 +187,7 @@ threads::shared - Perl extension for sharing data structures between threads
 
 =head1 VERSION
 
-This document describes threads::shared version 1.21
+This document describes threads::shared version 1.27
 
 =head1 SYNOPSIS
 
@@ -293,7 +294,7 @@ refs of shared data (discussed in next section):
 =item shared_clone REF
 
 C<shared_clone> 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/]});
@@ -307,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
 
@@ -531,6 +532,28 @@ circular references).  Use L<is_shared()/"is_shared VARIABLE">, instead:
         # The refs are equivalent
     }
 
+L<each()|perlfunc/"each HASH"> 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<http://rt.cpan.org/Public/Dist/Display.html?Name=threads-shared>
 
@@ -540,7 +563,7 @@ L<threads::shared> Discussion Forum on CPAN:
 L<http://www.cpanforum.com/dist/threads-shared>
 
 Annotated POD for L<threads::shared>:
-L<http://annocpan.org/~JDHEDDEN/threads-shared-1.21/shared.pm>
+L<http://annocpan.org/~JDHEDDEN/threads-shared-1.27/shared.pm>
 
 Source repository:
 L<http://code.google.com/p/threads-shared/>
@@ -557,10 +580,12 @@ L<http://lists.cpan.org/showlist.cgi?name=iThreads>
 
 Artur Bergman E<lt>sky AT crucially DOT netE<gt>
 
-threads::shared is released under the same license as Perl.
-
 Documentation borrowed from the old Thread.pm.
 
 CPAN version produced by Jerry D. Hedden E<lt>jdhedden AT cpan DOT orgE<gt>.
 
+=head1 LICENSE
+
+threads::shared is released under the same license as Perl.
+
 =cut