Skip to content

Commit

Permalink
threads v1.64
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhedden committed Apr 21, 2016
1 parent 8b55cbb commit 78bda88
Show file tree
Hide file tree
Showing 21 changed files with 213 additions and 107 deletions.
5 changes: 5 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Revision history for Perl extension threads.

1.64 Sun Aug 19 13:59:16 EDT 2007
- Documented cwd and %ENV issues wrt threads
- Sundry test suite fixes
- POD spelling test

1.63 Tue Jun 26 21:15:27 EDT 2007
- Avoid double-free of the thread function
- Added reference in POD to perlmod section on thread safety
Expand Down
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
threads version 1.63
threads version 1.64
====================

This module exposes interpreter threads to the Perl level.
Expand Down
2 changes: 1 addition & 1 deletion t/basic.t
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ ok(31, ! defined($thrx), 'No object');
$thrx = threads->object(0);
ok(32, ! defined($thrx), 'No object');

import threads 'stringify';
threads->import('stringify');
$thr1 = threads->create(sub {});
ok(33, "$thr1" eq $thr1->tid(), 'Stringify');
$thr1->join();
Expand Down
2 changes: 1 addition & 1 deletion t/blocks.t
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use threads;
BEGIN {
eval {
require threads::shared;
import threads::shared;
threads::shared->import();
};
if ($@ || ! $threads::shared::threads_shared) {
print("1..0 # Skip: threads::shared not available\n");
Expand Down
2 changes: 1 addition & 1 deletion t/context.t
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use threads;
BEGIN {
eval {
require threads::shared;
import threads::shared;
threads::shared->import();
};
if ($@ || ! $threads::shared::threads_shared) {
print("1..0 # Skip: threads::shared not available\n");
Expand Down
2 changes: 1 addition & 1 deletion t/end.t
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use threads;
BEGIN {
eval {
require threads::shared;
import threads::shared;
threads::shared->import();
};
if ($@ || ! $threads::shared::threads_shared) {
print("1..0 # Skip: threads::shared not available\n");
Expand Down
39 changes: 26 additions & 13 deletions t/exit.t
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ BEGIN {

require($ENV{PERL_CORE} ? "./test.pl" : "./t/test.pl");
}
our $TODO;

use ExtUtils::testlib;

Expand Down Expand Up @@ -56,13 +57,15 @@ my $rc = $thr->join();
ok(! defined($rc), 'Exited: threads->exit()');


run_perl(prog => 'use threads 1.63;' .
run_perl(prog => 'use threads 1.64;' .
'threads->exit(86);' .
'exit(99);',
nolib => ($ENV{PERL_CORE}) ? 0 : 1,
switches => ($ENV{PERL_CORE}) ? [] : [ '-Mblib' ]);
is($?>>8, 86, 'thread->exit(status) in main');

{
local $TODO = 'VMS exit semantics not like POSIX exit semantics' if $^O eq 'VMS';
is($?>>8, 86, 'thread->exit(status) in main');
}

$thr = threads->create({'exit' => 'thread_only'}, sub {
exit(1);
Expand Down Expand Up @@ -104,15 +107,17 @@ $rc = $thr->join();
ok(! defined($rc), 'Exited: $thr->set_thread_exit_only');


run_perl(prog => 'use threads 1.63 qw(exit thread_only);' .
run_perl(prog => 'use threads 1.64 qw(exit thread_only);' .
'threads->create(sub { exit(99); })->join();' .
'exit(86);',
nolib => ($ENV{PERL_CORE}) ? 0 : 1,
switches => ($ENV{PERL_CORE}) ? [] : [ '-Mblib' ]);
is($?>>8, 86, "'use threads 'exit' => 'thread_only'");

{
local $TODO = 'VMS exit semantics not like POSIX exit semantics' if $^O eq 'VMS';
is($?>>8, 86, "'use threads 'exit' => 'thread_only'");
}

my $out = run_perl(prog => 'use threads 1.63;' .
my $out = run_perl(prog => 'use threads 1.64;' .
'threads->create(sub {' .
' exit(99);' .
'});' .
Expand All @@ -121,11 +126,14 @@ my $out = run_perl(prog => 'use threads 1.63;' .
nolib => ($ENV{PERL_CORE}) ? 0 : 1,
switches => ($ENV{PERL_CORE}) ? [] : [ '-Mblib' ],
stderr => 1);
is($?>>8, 99, "exit(status) in thread");
{
local $TODO = 'VMS exit semantics not like POSIX exit semantics' if $^O eq 'VMS';
is($?>>8, 99, "exit(status) in thread");
}
like($out, '1 finished and unjoined', "exit(status) in thread");


$out = run_perl(prog => 'use threads 1.63 qw(exit thread_only);' .
$out = run_perl(prog => 'use threads 1.64 qw(exit thread_only);' .
'threads->create(sub {' .
' threads->set_thread_exit_only(0);' .
' exit(99);' .
Expand All @@ -135,20 +143,25 @@ $out = run_perl(prog => 'use threads 1.63 qw(exit thread_only);' .
nolib => ($ENV{PERL_CORE}) ? 0 : 1,
switches => ($ENV{PERL_CORE}) ? [] : [ '-Mblib' ],
stderr => 1);
is($?>>8, 99, "set_thread_exit_only(0)");
{
local $TODO = 'VMS exit semantics not like POSIX exit semantics' if $^O eq 'VMS';
is($?>>8, 99, "set_thread_exit_only(0)");
}
like($out, '1 finished and unjoined', "set_thread_exit_only(0)");


run_perl(prog => 'use threads 1.63;' .
run_perl(prog => 'use threads 1.64;' .
'threads->create(sub {' .
' $SIG{__WARN__} = sub { exit(99); };' .
' die();' .
'})->join();' .
'exit(86);',
nolib => ($ENV{PERL_CORE}) ? 0 : 1,
switches => ($ENV{PERL_CORE}) ? [] : [ '-Mblib' ]);
is($?>>8, 99, "exit(status) in thread warn handler");

{
local $TODO = 'VMS exit semantics not like POSIX exit semantics' if $^O eq 'VMS';
is($?>>8, 99, "exit(status) in thread warn handler");
}

$thr = threads->create(sub {
$SIG{__WARN__} = sub { threads->exit(); };
Expand Down
2 changes: 1 addition & 1 deletion t/free.t
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use threads;
BEGIN {
eval {
require threads::shared;
import threads::shared;
threads::shared->import();
};
if ($@ || ! $threads::shared::threads_shared) {
print("1..0 # Skip: threads::shared not available\n");
Expand Down
2 changes: 1 addition & 1 deletion t/free2.t
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use threads;
BEGIN {
eval {
require threads::shared;
import threads::shared;
threads::shared->import();
};
if ($@ || ! $threads::shared::threads_shared) {
print("1..0 # Skip: threads::shared not available\n");
Expand Down
2 changes: 1 addition & 1 deletion t/join.t
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use threads;
BEGIN {
eval {
require threads::shared;
import threads::shared;
threads::shared->import();
};
if ($@ || ! $threads::shared::threads_shared) {
print("1..0 # Skip: threads::shared not available\n");
Expand Down
2 changes: 1 addition & 1 deletion t/kill.t
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use threads;
BEGIN {
eval {
require threads::shared;
import threads::shared;
threads::shared->import();
};
if ($@ || ! $threads::shared::threads_shared) {
print("1..0 # Skip: threads::shared not available\n");
Expand Down
35 changes: 33 additions & 2 deletions t/pod.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use warnings;
BEGIN {
eval {
require Test::More;
import Test::More 'tests' => 2;
Test::More->import('tests' => 3);
};
if ($@) {
print("1..0 # Skip: Test::More not available\n");
Expand Down Expand Up @@ -41,4 +41,35 @@ SKIP: {
);
}

# EOF
SKIP: {
eval "use Test::Spelling";
skip("Test::Spelling required for testing POD spelling", 1) if $@;
set_spell_cmd('aspell -l --lang=en');
add_stopwords(<DATA>);
pod_file_spelling_ok('blib/lib/threads.pm', 'thread.pm spelling');
}

__DATA__
API
async
cpan
MSWin32
pthreads
SIGTERM
TID
Hedden
Soderberg
crystalflame
brecon
netrus
vipul
Ved
Prakash
presicient
okay
unjoinable
__END__
2 changes: 1 addition & 1 deletion t/problems.t
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use threads;
BEGIN {
eval {
require threads::shared;
import threads::shared;
threads::shared->import();
};
if ($@ || ! $threads::shared::threads_shared) {
print("1..0 # Skip: threads::shared not available\n");
Expand Down
42 changes: 21 additions & 21 deletions t/stack.t
Original file line number Diff line number Diff line change
Expand Up @@ -34,72 +34,72 @@ BEGIN {
print("1..18\n"); ### Number of tests that will be run ###
};

use threads ('stack_size' => 32*4096);
use threads ('stack_size' => 128*4096);
ok(1, 1, 'Loaded');

### Start of Testing ###

ok(2, threads->get_stack_size() == 32*4096,
ok(2, threads->get_stack_size() == 128*4096,
'Stack size set in import');
ok(3, threads->set_stack_size(64*4096) == 32*4096,
ok(3, threads->set_stack_size(160*4096) == 128*4096,
'Set returns previous value');
ok(4, threads->get_stack_size() == 64*4096,
ok(4, threads->get_stack_size() == 160*4096,
'Get stack size');

threads->create(
sub {
ok(5, threads->get_stack_size() == 64*4096,
ok(5, threads->get_stack_size() == 160*4096,
'Get stack size in thread');
ok(6, threads->self()->get_stack_size() == 64*4096,
ok(6, threads->self()->get_stack_size() == 160*4096,
'Thread gets own stack size');
ok(7, threads->set_stack_size(32*4096) == 64*4096,
ok(7, threads->set_stack_size(128*4096) == 160*4096,
'Thread changes stack size');
ok(8, threads->get_stack_size() == 32*4096,
ok(8, threads->get_stack_size() == 128*4096,
'Get stack size in thread');
ok(9, threads->self()->get_stack_size() == 64*4096,
ok(9, threads->self()->get_stack_size() == 160*4096,
'Thread stack size unchanged');
}
)->join();

ok(10, threads->get_stack_size() == 32*4096,
ok(10, threads->get_stack_size() == 128*4096,
'Default thread sized changed in thread');

threads->create(
{ 'stack' => 64*4096 },
{ 'stack' => 160*4096 },
sub {
ok(11, threads->get_stack_size() == 32*4096,
ok(11, threads->get_stack_size() == 128*4096,
'Get stack size in thread');
ok(12, threads->self()->get_stack_size() == 64*4096,
ok(12, threads->self()->get_stack_size() == 160*4096,
'Thread gets own stack size');
}
)->join();

my $thr = threads->create( { 'stack' => 64*4096 }, sub { } );
my $thr = threads->create( { 'stack' => 160*4096 }, sub { } );

$thr->create(
sub {
ok(13, threads->get_stack_size() == 32*4096,
ok(13, threads->get_stack_size() == 128*4096,
'Get stack size in thread');
ok(14, threads->self()->get_stack_size() == 64*4096,
ok(14, threads->self()->get_stack_size() == 160*4096,
'Thread gets own stack size');
}
)->join();

$thr->create(
{ 'stack' => 48*4096 },
{ 'stack' => 144*4096 },
sub {
ok(15, threads->get_stack_size() == 32*4096,
ok(15, threads->get_stack_size() == 128*4096,
'Get stack size in thread');
ok(16, threads->self()->get_stack_size() == 48*4096,
ok(16, threads->self()->get_stack_size() == 144*4096,
'Thread gets own stack size');
ok(17, threads->set_stack_size(64*4096) == 32*4096,
ok(17, threads->set_stack_size(160*4096) == 128*4096,
'Thread changes stack size');
}
)->join();

$thr->join();

ok(18, threads->get_stack_size() == 64*4096,
ok(18, threads->get_stack_size() == 160*4096,
'Default thread sized changed in thread');

# EOF
8 changes: 4 additions & 4 deletions t/stack_env.t
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ BEGIN {
$| = 1;
print("1..4\n"); ### Number of tests that will be run ###

$ENV{'PERL5_ITHREADS_STACK_SIZE'} = 196608;
$ENV{'PERL5_ITHREADS_STACK_SIZE'} = 128*4096;
};

use threads;
ok(1, 1, 'Loaded');

### Start of Testing ###

ok(2, threads->get_stack_size() == 48*4096,
ok(2, threads->get_stack_size() == 128*4096,
'$ENV{PERL5_ITHREADS_STACK_SIZE}');
ok(3, threads->set_stack_size(32*4096) == 48*4096,
ok(3, threads->set_stack_size(144*4096) == 128*4096,
'Set returns previous value');
ok(4, threads->get_stack_size() == 32*4096,
ok(4, threads->get_stack_size() == 144*4096,
'Get stack size');

# EOF
2 changes: 1 addition & 1 deletion t/state.t
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use threads;
BEGIN {
eval {
require threads::shared;
import threads::shared;
threads::shared->import();
};
if ($@ || ! $threads::shared::threads_shared) {
print("1..0 # Skip: threads::shared not available\n");
Expand Down
Loading

0 comments on commit 78bda88

Please sign in to comment.