Be polite and destroy the mutexes and conditions we use!
[p5sagit/p5-mst-13.2.git] / ext / threads / shared / shared.pm
index 3b41a30..64ab079 100644 (file)
@@ -3,24 +3,26 @@ package threads::shared;
 use 5.007_003;
 use strict;
 use warnings;
+BEGIN {
+    require Exporter;
+    our @ISA = qw(Exporter);
+    our @EXPORT = qw(share cond_wait cond_broadcast cond_signal);
+    our $VERSION = '0.90';
 
-require Exporter;
-our @ISA = qw(Exporter);
-our @EXPORT = qw(share cond_wait cond_broadcast cond_signal);
-our $VERSION = '0.90';
-
-if ($threads::threads) {
+    if ($threads::threads) {
        *cond_wait = \&cond_wait_enabled;
        *cond_signal = \&cond_signal_enabled;
        *cond_broadcast = \&cond_broadcast_enabled;
        require XSLoader;
        XSLoader::load('threads::shared',$VERSION);
-}
-else {
+       push @EXPORT,'bless';
+    }
+    else {
        *share = \&share_disabled;
        *cond_wait = \&cond_wait_disabled;
        *cond_signal = \&cond_signal_disabled;
        *cond_broadcast = \&cond_broadcast_disabled;
+    }
 }
 
 
@@ -182,10 +184,10 @@ Taking references to the elements of shared arrays and hashes does not
 autovivify the elements, and neither does slicing a shared array/hash
 over non-existent indices/keys autovivify the elements.
 
-share() allows you to C<share $hashref->{key}> without giving any error
-message.  But the C<$hashref->{key}> is B<not> shared, causing the error
+share() allows you to C<< share $hashref->{key} >> without giving any error
+message.  But the C<< $hashref->{key} >> is B<not> shared, causing the error
 "locking can only be used on shared values" to occur when you attempt to
-C<lock $hasref->{key}>.
+C<< lock $hasref->{key} >>.
 
 =head1 AUTHOR