ok(! defined($rc), 'Exited: threads->exit()');
-run_perl(prog => 'use threads 1.58;' .
+run_perl(prog => 'use threads 1.59;' .
'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.58 qw(exit thread_only);' .
+run_perl(prog => 'use threads 1.59 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.58;' .
+my $out = run_perl(prog => 'use threads 1.59;' .
'threads->create(sub {' .
' exit(99);' .
'});' .
like($out, '1 finished and unjoined', "exit(status) in thread");
-$out = run_perl(prog => 'use threads 1.58 qw(exit thread_only);' .
+$out = run_perl(prog => 'use threads 1.59 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.58;' .
+run_perl(prog => 'use threads 1.59;' .
'threads->create(sub {' .
' $SIG{__WARN__} = sub { exit(99); };' .
' die();' .
use strict;
use warnings;
-our $VERSION = '1.58';
+our $VERSION = '1.59';
my $XS_VERSION = $VERSION;
$VERSION = eval $VERSION;
=head1 VERSION
-This document describes threads version 1.58
+This document describes threads version 1.59
=head1 SYNOPSIS
C<async> creates a thread to execute the block immediately following
it. This block is treated as an anonymous subroutine, and so must have a
-semi-colon after the closing brace. Like C<threads->create()>, C<async>
+semicolon after the closing brace. Like C<threads-E<gt>create()>, C<async>
returns a I<threads> object.
=item $thr->error()
threads->exit() if threads->can('exit'); # Thread friendly
exit(status);
-=item use threads 'exit' => 'thread_only'
+=item use threads 'exit' => 'threads_only'
This globally overrides the default behavior of calling C<exit()> inside a
thread, and effectively causes such calls to behave the same as
=item $thr->set_thread_exit_only(boolean)
This can be used to change the I<exit thread only> behavior for a thread after
-it has been created. With a I<true> argument, C<exit()> will cause the only
-the thread to exit. With a I<false> argument, C<exit()> will terminate the
+it has been created. With a I<true> argument, C<exit()> will cause only the
+thread to exit. With a I<false> argument, C<exit()> will terminate the
application.
The I<main> thread is unaffected by this call.
=item threads->set_thread_exit_only(boolean)
-Class method for use inside a thread to changes its own behavior for
-C<exit()>.
+Class method for use inside a thread to change its own behavior for C<exit()>.
The I<main> thread is unaffected by this call.
=item $thr->is_running()
Returns true if a thread is still running (i.e., if its entry point function
-has not yet finished/exited).
+has not yet finished or exited).
=item $thr->is_joinable()
Returns true if the thread has finished running, is not detached and has not
-yet been joined. In other works, the thread is ready to be joined and will
-not I<block>.
+yet been joined. In other words, the thread is ready to be joined, and a call
+to C<$thr-E<gt>join()> will not I<block>.
=item $thr->is_detached()
Because thread creation and thread joining may occur in different contexts, it
may be desirable to state the context explicitly to the thread's entry point
-function. This may be done by calling C<-E<gt>create()> with a parameter hash
+function. This may be done by calling C<-E<gt>create()> with a hash reference
as the first argument:
my $thr = threads->create({'context' => 'list'}, \&foo);
...
$thr->join();
-The context type may also be used as the I<key> in the parameter hash followed
+The context type may also be used as the I<key> in the hash reference followed
by a I<true> value:
threads->create({'scalar' => 1}, \&foo);
=head2 threads->wantarray()
-Class method to return the current thread's context. This is the same as
-running L<wantarray()|perlfunc/"wantarray"> in the current thread.
+Class method to return the current thread's context. This returns the same
+value as running L<wantarray()|perlfunc/"wantarray"> inside the current
+thread's entry point function.
=head1 THREAD STACK SIZE
you may significantly reduce your application's memory usage, and increase the
number of simultaneously running threads.
-N.B., on Windows, Address space allocation granularity is 64 KB, therefore,
-setting the stack smaller than that on Win32 Perl will not save any more
-memory.
+Note that on Windows, address space allocation granularity is 64 KB,
+therefore, setting the stack smaller than that on Win32 Perl will not save any
+more memory.
=over
=item threads->create({'stack_size' => VALUE}, FUNCTION, ARGS)
-The stack size an individual threads may also be specified. This may be done
-by calling C<-E<gt>create()> with a parameter hash as the first argument:
+To specify a particular stack size for any individual thread, call
+C<-E<gt>create()> with a hash reference as the first argument:
my $thr = threads->create({'stack_size' => 32*4096}, \&foo, @args);
...
}
- # Create a semaphore and send it to a thread
+ # Create a semaphore and pass it to a thread
my $sema = Thread::Semaphore->new();
my $thr = threads->create('thr_func', $sema);
A thread terminated in some manner other than just returning from its entry
point function, or by using C<threads-E<gt>exit()>. For example, the thread
-may have terminated because of a error, or by using C<die>.
+may have terminated because of an error, or by using C<die>.
=item Using minimum thread stack size of #
=item Using non-threadsafe modules
-Unfortunately, you may encounter Perl modules are not I<threadsafe>. For
+Unfortunately, you may encounter Perl modules that are not I<threadsafe>. For
example, they may crash the Perl interpreter during execution, or may dump
core on termination. Depending on the module and the requirements of your
application, it may be possible to work around such difficulties.
=over 4
-=item * Perl was been built with C<PERL_OLD_SIGNALS> (see C<perl -V>).
+=item * Perl has been built with C<PERL_OLD_SIGNALS> (see C<perl -V>).
=item * The environment variable C<PERL_SIGNALS> is set to C<unsafe> (see L<perlrun/"PERL_SIGNALS">).
=item Perl Bugs and the CPAN Version of L<threads>
-Support for threads extents beyond the code in this module (i.e.,
+Support for threads extends beyond the code in this module (i.e.,
F<threads.pm> and F<threads.xs>), and into the Perl iterpreter itself. Older
versions of Perl contain bugs that may manifest themselves despite using the
latest version of L<threads> from CPAN. There is no workaround for this other
L<http://www.cpanforum.com/dist/threads>
Annotated POD for L<threads>:
-L<http://annocpan.org/~JDHEDDEN/threads-1.58/threads.pm>
+L<http://annocpan.org/~JDHEDDEN/threads-1.59/threads.pm>
L<threads::shared>, L<perlthrtut>