ok(! defined($rc), 'Exited: threads->exit()');
-run_perl(prog => 'use threads 1.73;' .
+run_perl(prog => 'use threads 1.74;' .
'threads->exit(86);' .
'exit(99);',
nolib => ($ENV{PERL_CORE}) ? 0 : 1,
ok(! defined($rc), 'Exited: $thr->set_thread_exit_only');
-run_perl(prog => 'use threads 1.73 qw(exit thread_only);' .
+run_perl(prog => 'use threads 1.74 qw(exit thread_only);' .
'threads->create(sub { exit(99); })->join();' .
'exit(86);',
nolib => ($ENV{PERL_CORE}) ? 0 : 1,
is($?>>8, 86, "'use threads 'exit' => 'thread_only'");
}
-my $out = run_perl(prog => 'use threads 1.73;' .
+my $out = run_perl(prog => 'use threads 1.74;' .
'threads->create(sub {' .
' exit(99);' .
'});' .
like($out, '1 finished and unjoined', "exit(status) in thread");
-$out = run_perl(prog => 'use threads 1.73 qw(exit thread_only);' .
+$out = run_perl(prog => 'use threads 1.74 qw(exit thread_only);' .
'threads->create(sub {' .
' threads->set_thread_exit_only(0);' .
' exit(99);' .
like($out, '1 finished and unjoined', "set_thread_exit_only(0)");
-run_perl(prog => 'use threads 1.73;' .
+run_perl(prog => 'use threads 1.74;' .
'threads->create(sub {' .
' $SIG{__WARN__} = sub { exit(99); };' .
' die();' .
--- /dev/null
+use strict;
+use warnings;
+
+BEGIN {
+ use Config;
+ if ($Config{'useithreads'}) {
+ print("1..0 # SKIP Perl compiled with 'useithreads'\n");
+ exit(0);
+ }
+}
+
+use ExtUtils::testlib;
+
+sub ok {
+ my ($id, $ok, $name) = @_;
+
+ # You have to do it this way or VMS will get confused.
+ if ($ok) {
+ print("ok $id - $name\n");
+ } else {
+ print("not ok $id - $name\n");
+ printf("# Failed test at line %d\n", (caller)[2]);
+ }
+
+ return ($ok);
+}
+
+BEGIN {
+ $| = 1;
+ print("1..1\n"); ### Number of tests that will be run ###
+};
+
+eval 'use threads; 1';
+
+ok(1, (($@ =~ /not built to support thread/)?1:0), "No threads support");
+
+exit(0);
+
+# EOF
use strict;
use warnings;
-our $VERSION = '1.73';
+our $VERSION = '1.74';
my $XS_VERSION = $VERSION;
$VERSION = eval $VERSION;
=head1 VERSION
-This document describes threads version 1.73
+This document describes threads version 1.74
=head1 SYNOPSIS
=head1 DESCRIPTION
-Perl 5.6 introduced something called interpreter threads. Interpreter threads
-are different from I<5005threads> (the thread model of Perl 5.005) by creating
-a new Perl interpreter per thread, and not sharing any data or state between
-threads by default.
+Since Perl 5.8, thread programming has been available using a model called
+I<interpreter threads> which provides a new Perl interpreter for each
+thread, and, by default, results in no data or state information being shared
+between threads.
-Prior to Perl 5.8, this has only been available to people embedding Perl, and
-for emulating fork() on Windows.
+(Prior to Perl 5.8, I<5005threads> was available through the C<Thread.pm> API.
+This threading model has been deprecated, and was removed as of Perl 5.10.0.)
-The I<threads> API is loosely based on the old Thread.pm API. It is very
-important to note that variables are not shared between threads, all variables
-are by default thread local. To use shared variables one must also use
-L<threads::shared>:
+As just mentioned, all variables are, by default, thread local. To use shared
+variables, you need to also load L<threads::shared>:
use threads;
use threads::shared;
-It is also important to note that you must enable threads by doing C<use
-threads> as early as possible in the script itself, and that it is not
-possible to enable threading inside an C<eval "">, C<do>, C<require>, or
-C<use>. In particular, if you are intending to share variables with
-L<threads::shared>, you must C<use threads> before you C<use threads::shared>.
-(C<threads> will emit a warning if you do it the other way around.)
+When loading L<threads::shared>, you must C<use threads> before you
+C<use threads::shared>. (C<threads> will emit a warning if you do it the
+other way around.)
+
+It is strongly recommended that you enable threads via C<use threads> as early
+as possible in your script.
+
+If needed, scripts can be written so as to run on both threaded and
+non-threaded Perls:
+
+ my $can_use_threads = eval 'use threads; 1';
+ if ($can_use_threads) {
+ # Do processing using threads
+ ...
+ } else {
+ # Do it without using threads
+ ...
+ }
=over
L<http://www.cpanforum.com/dist/threads>
Annotated POD for L<threads>:
-L<http://annocpan.org/~JDHEDDEN/threads-1.73/threads.pm>
+L<http://annocpan.org/~JDHEDDEN/threads-1.74/threads.pm>
Source repository:
L<http://code.google.com/p/threads-shared/>