diff options
author | jdhedden <jdhedden@cpan.org> | 2016-04-22 14:28:09 -0400 |
---|---|---|
committer | Ricardo Signes <rjbs@cpan.org> | 2016-04-30 14:29:50 -0400 |
commit | d9262b38948c21dc22d00f0f094ad37ee3b98430 (patch) | |
tree | ac05ffce98277a189700603ac5661dc42b4476f1 /dist | |
parent | 8a355c193e75b3d8ec3222d4e11e62b945626cb8 (diff) | |
download | perl-d9262b38948c21dc22d00f0f094ad37ee3b98430.tar.gz |
Upgrade to threads 2.06
Diffstat (limited to 'dist')
-rw-r--r-- | dist/threads/lib/threads.pm | 17 | ||||
-rw-r--r-- | dist/threads/t/exit.t | 10 | ||||
-rw-r--r-- | dist/threads/t/thread.t | 2 | ||||
-rw-r--r-- | dist/threads/threads.xs | 28 |
4 files changed, 28 insertions, 29 deletions
diff --git a/dist/threads/lib/threads.pm b/dist/threads/lib/threads.pm index f4dee58fd6..9feb4c30d8 100644 --- a/dist/threads/lib/threads.pm +++ b/dist/threads/lib/threads.pm @@ -134,7 +134,7 @@ threads - Perl interpreter-based threads =head1 VERSION -This document describes threads version 2.02 +This document describes threads version 2.06 =head1 WARNING @@ -363,10 +363,10 @@ If you add the C<stringify> import option to your C<use threads> declaration, then using a threads object in a string or a string context (e.g., as a hash key) will cause its ID to be used as the value: - use threads qw(stringify); + use threads qw(stringify); - my $thr = threads->create(...); - print("Thread $thr started...\n"); # Prints: Thread 1 started... + my $thr = threads->create(...); + print("Thread $thr started\n"); # Prints: Thread 1 started =item threads->object($tid) @@ -691,16 +691,17 @@ threaded applications. 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); + my $thr = threads->create({'stack_size' => 32*4096}, + \&foo, @args); =item $thr2 = $thr1->create(FUNCTION, ARGS) This creates a new thread (C<$thr2>) that inherits the stack size from an existing thread (C<$thr1>). This is shorthand for the following: - my $stack_size = $thr1->get_stack_size(); - my $thr2 = threads->create({'stack_size' => $stack_size}, - FUNCTION, ARGS); + my $stack_size = $thr1->get_stack_size(); + my $thr2 = threads->create({'stack_size' => $stack_size}, + FUNCTION, ARGS); =back diff --git a/dist/threads/t/exit.t b/dist/threads/t/exit.t index 908f52c8c7..016c1359e4 100644 --- a/dist/threads/t/exit.t +++ b/dist/threads/t/exit.t @@ -48,7 +48,7 @@ my $rc = $thr->join(); ok(! defined($rc), 'Exited: threads->exit()'); -run_perl(prog => 'use threads 2.02;' . +run_perl(prog => 'use threads 2.06;' . 'threads->exit(86);' . 'exit(99);', nolib => ($ENV{PERL_CORE}) ? 0 : 1, @@ -98,7 +98,7 @@ $rc = $thr->join(); ok(! defined($rc), 'Exited: $thr->set_thread_exit_only'); -run_perl(prog => 'use threads 2.02 qw(exit thread_only);' . +run_perl(prog => 'use threads 2.06 qw(exit thread_only);' . 'threads->create(sub { exit(99); })->join();' . 'exit(86);', nolib => ($ENV{PERL_CORE}) ? 0 : 1, @@ -108,7 +108,7 @@ run_perl(prog => 'use threads 2.02 qw(exit thread_only);' . is($?>>8, 86, "'use threads 'exit' => 'thread_only'"); } -my $out = run_perl(prog => 'use threads 2.02;' . +my $out = run_perl(prog => 'use threads 2.06;' . 'threads->create(sub {' . ' exit(99);' . '});' . @@ -124,7 +124,7 @@ my $out = run_perl(prog => 'use threads 2.02;' . like($out, qr/1 finished and unjoined/, "exit(status) in thread"); -$out = run_perl(prog => 'use threads 2.02 qw(exit thread_only);' . +$out = run_perl(prog => 'use threads 2.06 qw(exit thread_only);' . 'threads->create(sub {' . ' threads->set_thread_exit_only(0);' . ' exit(99);' . @@ -141,7 +141,7 @@ $out = run_perl(prog => 'use threads 2.02 qw(exit thread_only);' . like($out, qr/1 finished and unjoined/, "set_thread_exit_only(0)"); -run_perl(prog => 'use threads 2.02;' . +run_perl(prog => 'use threads 2.06;' . 'threads->create(sub {' . ' $SIG{__WARN__} = sub { exit(99); };' . ' die();' . diff --git a/dist/threads/t/thread.t b/dist/threads/t/thread.t index 56087f3293..c1218da981 100644 --- a/dist/threads/t/thread.t +++ b/dist/threads/t/thread.t @@ -161,7 +161,7 @@ package main; # bugid #24165 -run_perl(prog => 'use threads 2.02;' . +run_perl(prog => 'use threads 2.06;' . 'sub a{threads->create(shift)} $t = a sub{};' . '$t->tid; $t->join; $t->tid', nolib => ($ENV{PERL_CORE}) ? 0 : 1, diff --git a/dist/threads/threads.xs b/dist/threads/threads.xs index d35eee17b2..5f521928a1 100644 --- a/dist/threads/threads.xs +++ b/dist/threads/threads.xs @@ -20,13 +20,12 @@ #endif #ifdef HAS_PPPORT_H # define NEED_PL_signals -# define NEED_newRV_noinc # define NEED_sv_2pv_flags # include "ppport.h" # include "threads.h" #endif #ifndef sv_dup_inc -# define sv_dup_inc(s,t) SvREFCNT_inc(sv_dup(s,t)) +# define sv_dup_inc(s,t) SvREFCNT_inc(sv_dup(s,t)) #endif #ifndef PERL_UNUSED_RESULT # if defined(__GNUC__) && defined(HASATTRIBUTE_WARN_UNUSED_RESULT) @@ -476,13 +475,13 @@ S_good_stack_size(pTHX_ IV stack_size) return (stack_size); } -/* run some code within a JMPENV environment. - * Having it in a separate small function helps avoid - * 'variable ‘foo’ might be clobbered by ‘longjmp’ + +/* Run code within a JMPENV environment. + * Using a separate function avoids + * "variable 'foo' might be clobbered by 'longjmp'" * warnings. * The three _p vars return values to the caller */ - static int S_jmpenv_run(pTHX_ int action, ithread *thread, int *len_p, int *exit_app_p, int *exit_code_p) @@ -496,12 +495,10 @@ S_jmpenv_run(pTHX_ int action, ithread *thread, if (action == 0) { /* Run the specified function */ *len_p = (int)call_sv(thread->init_function, thread->gimme|G_EVAL); - } - else if (action == 1) { + } else if (action == 1) { /* Warn that thread died */ Perl_warn(aTHX_ "Thread %" UVuf " terminated abnormally: %" SVf, thread->tid, ERRSV); - } - else { + } else { /* Warn if there are unjoined threads */ S_exit_warning(aTHX); } @@ -1018,8 +1015,9 @@ S_ithread_create( my_pool->running_threads++; MUTEX_UNLOCK(&my_pool->create_destruct_mutex); return (thread); -CLANG_DIAG_IGNORE(-Wthread-safety); -/* warning: mutex 'thread->mutex' is not held on every path through here [-Wthread-safety-analysis] */ + + CLANG_DIAG_IGNORE(-Wthread-safety); + /* warning: mutex 'thread->mutex' is not held on every path through here [-Wthread-safety-analysis] */ } #if defined(__clang__) || defined(__clang) CLANG_DIAG_RESTORE; @@ -1161,10 +1159,10 @@ ithread_create(...) /* Let thread run. */ /* See S_ithread_run() for more detail. */ - CLANG_DIAG_IGNORE(-Wthread-safety); - /* warning: releasing mutex 'thread->mutex' that was not held [-Wthread-safety-analysis] */ + CLANG_DIAG_IGNORE(-Wthread-safety); + /* warning: releasing mutex 'thread->mutex' that was not held [-Wthread-safety-analysis] */ MUTEX_UNLOCK(&thread->mutex); - CLANG_DIAG_RESTORE; + CLANG_DIAG_RESTORE; /* XSRETURN(1); - implied */ |