This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make hv_notallowed a static as suggested by Nicholas Clark;
[perl5.git] / lib / Thread.pm
index c648954..fc39769 100644 (file)
@@ -1,13 +1,11 @@
 package Thread;
 
-$VERSION = '2.00';
-
 use strict;
 
-our $ithreads;
-our $othreads;
+our($VERSION, $ithreads, $othreads);
 
 BEGIN {
+    $VERSION = '2.00';
     use Config;
     $ithreads = $Config{useithreads};
     $othreads = $Config{use5005threads};
@@ -15,7 +13,7 @@ BEGIN {
 
 require Exporter;
 use XSLoader ();
-our($VERSION, @ISA, @EXPORT, @EXPORT_OK);
+our(@ISA, @EXPORT, @EXPORT_OK);
 
 @ISA = qw(Exporter);
 
@@ -52,15 +50,24 @@ In Perl 5.8 the ithreads model became available through the C<threads>
 module.
 
 Neither model is configured by default into Perl (except, as mentioned
-above, in Win32 ithreads are always available.)
+above, in Win32 ithreads are always available.)  You can see your
+Perl's threading configuration by running C<perl -V> and looking for
+the I<use...threads> variables, or inside script by C<use Config;>
+and testing for C<$Config{use5005threads}> and C<$Config{useithreads}>.
+
+For old code and interim backwards compatibility, the Thread module
+has been reworked to function as a frontend for both 5005threads and
+ithreads.
 
-For backwards compatibility, the Thread module has been reworked
-to function as a frontend for both 5005threads and ithreads.
 Note that the compatibility is not complete: because the data sharing
 models are directly opposed, anything to do with data sharing has to
 be thought differently.  With the ithreads you must explicitly share()
 variables between the threads.
 
+For new code the use of the C<Thread> module is discouraged and
+the direct use use of the C<threads> and C<threads::shared> modules
+is encouraged instead.
+
 Finally, note that there are many known serious problems with the
 5005threads, one of the least of which is that regular expression
 match variables like $1 are not threadsafe, that is, they easily get
@@ -306,6 +313,10 @@ sub unimplement {
 
 BEGIN {
     if ($ithreads) {
+       if ($othreads) {
+           require Carp;
+           Carp::croak("This Perl has both ithreads and 5005threads (serious malconfiguration)");
+       }
        XSLoader::load 'threads';
        for my $m (qw(new join detach yield self tid equal)) {
            no strict 'refs';
@@ -323,7 +334,7 @@ BEGIN {
        unimplement(qw(unlock));
     } else {
        require Carp;
-       Carp::croak("This Perl has neither ithreads not 5005threads");
+       Carp::croak("This Perl has neither ithreads nor 5005threads");
     }
 }