Change 30310 by [EMAIL PROTECTED] on 2007/02/15 09:34:01
Subject: [PATCH] Use newer 'threads' constructs
From: "Jerry D. Hedden" <[EMAIL PROTECTED]>
Date: Mon, 12 Feb 2007 12:04:33 -0800 (PST)
Message-ID: <[EMAIL PROTECTED]>
Affected files ...
... //depot/perl/ext/XS/APItest/t/my_cxt.t#2 edit
... //depot/perl/ext/threads/shared/t/blessed.t#3 edit
... //depot/perl/ext/threads/shared/t/cond.t#16 edit
... //depot/perl/ext/threads/shared/t/hv_refs.t#13 edit
... //depot/perl/ext/threads/threads.xs#137 edit
... //depot/perl/lib/Thread/Queue.t#2 edit
... //depot/perl/lib/perl5db.pl#127 edit
... //depot/perl/pod/perlapi.pod#286 edit
... //depot/perl/pod/perlxs.pod#50 edit
... //depot/perl/sv.c#1367 edit
... //depot/perl/t/op/threads.t#9 edit
Differences ...
==== //depot/perl/ext/XS/APItest/t/my_cxt.t#2 (text) ====
Index: perl/ext/XS/APItest/t/my_cxt.t
--- perl/ext/XS/APItest/t/my_cxt.t#1~26522~ 2005-12-29 03:35:04.000000000
-0800
+++ perl/ext/XS/APItest/t/my_cxt.t 2007-02-15 01:34:01.000000000 -0800
@@ -50,7 +50,7 @@
SKIP: {
skip "No threads", 4 unless $threads;
- threads->new(\&do_thread)->join;
+ threads->create(\&do_thread)->join;
}
is(my_cxt_getint(), 1234, "int value preserved after join");
==== //depot/perl/ext/threads/shared/t/blessed.t#3 (text) ====
Index: perl/ext/threads/shared/t/blessed.t
--- perl/ext/threads/shared/t/blessed.t#2~28923~ 2006-10-03
06:46:26.000000000 -0700
+++ perl/ext/threads/shared/t/blessed.t 2007-02-15 01:34:01.000000000 -0800
@@ -48,7 +48,7 @@
share($sref);
$sobj = $sref;
-threads->new(sub {
+threads->create(sub {
# Bless objects
bless $hobj, 'foo';
bless $aobj, 'bar';
@@ -99,7 +99,7 @@
ok(24, ref($$hobj{'scalar'}) eq 'baz', "blessed scalar in hash");
ok(25, ${$$hobj{'scalar'}} eq '3', "blessed scalar in hash contents");
-threads->new(sub {
+threads->create(sub {
# Rebless objects
bless $hobj, 'oof';
bless $aobj, 'rab';
==== //depot/perl/ext/threads/shared/t/cond.t#16 (text) ====
Index: perl/ext/threads/shared/t/cond.t
--- perl/ext/threads/shared/t/cond.t#15~29599~ 2006-12-19 20:20:14.000000000
-0800
+++ perl/ext/threads/shared/t/cond.t 2007-02-15 01:34:01.000000000 -0800
@@ -212,7 +212,7 @@
lock($counter);
if ($n > 0) {
$counter++;
- $th = threads->new(\&broad, $n-1);
+ $th = threads->create(\&broad, $n-1);
cond_wait($counter);
$counter += 10;
}
@@ -224,7 +224,7 @@
$th->join if $th;
}
- threads->new(\&broad, 3)->join;
+ threads->create(\&broad, 3)->join;
ok(2, $counter == 33, "cond_broadcast: all three threads woken");
$Base += 2;
@@ -243,7 +243,7 @@
lock($r);
if ($n > 0) {
$$r++;
- $th = threads->new(\&broad2, $n-1);
+ $th = threads->create(\&broad2, $n-1);
cond_wait($r);
$$r += 10;
}
@@ -255,7 +255,7 @@
$th->join if $th;
}
- threads->new(\&broad2, 3)->join;;
+ threads->create(\&broad2, 3)->join;;
ok(2, $$r == 33, "cond_broadcast: ref: all three threads woken");
$Base += 2;
==== //depot/perl/ext/threads/shared/t/hv_refs.t#13 (text) ====
Index: perl/ext/threads/shared/t/hv_refs.t
--- perl/ext/threads/shared/t/hv_refs.t#12~28923~ 2006-10-03
06:46:26.000000000 -0700
+++ perl/ext/threads/shared/t/hv_refs.t 2007-02-15 01:34:01.000000000 -0800
@@ -97,7 +97,7 @@
}
{
my $object : shared = &share({});
- threads->new(sub {
+ threads->create(sub {
bless $object, 'test1';
})->join;
ok(16, ref($object) eq 'test1', "blessing does work");
==== //depot/perl/ext/threads/threads.xs#137 (xtext) ====
Index: perl/ext/threads/threads.xs
--- perl/ext/threads/threads.xs#136~29973~ 2007-01-25 06:48:49.000000000
-0800
+++ perl/ext/threads/threads.xs 2007-02-15 01:34:01.000000000 -0800
@@ -637,7 +637,7 @@
* 1 ref to be the responsibility of join/detach, so we don't get
* freed until join/detach, even if no thread objects remain.
* This allows the following to work:
- * { threads->new(sub{...}); } threads->object(1)->join;
+ * { threads->create(sub{...}); } threads->object(1)->join;
*/
thread->count = 3;
==== //depot/perl/lib/Thread/Queue.t#2 (text) ====
Index: perl/lib/Thread/Queue.t
--- perl/lib/Thread/Queue.t#1~17509~ 2002-07-12 16:44:17.000000000 -0700
+++ perl/lib/Thread/Queue.t 2007-02-15 01:34:01.000000000 -0800
@@ -27,7 +27,7 @@
}
sub reader {
- my $tid = threads->self->tid;
+ my $tid = threads->tid;
my $i = 0;
while (1) {
$i++;
@@ -49,7 +49,7 @@
my @threads;
for (my $i = 0; $i < $nthreads; $i++) {
- push @threads, threads->new(\&reader, $i);
+ push @threads, threads->create(\&reader, $i);
}
for (my $i = 1; $i <= 20; $i++) {
==== //depot/perl/lib/perl5db.pl#127 (text) ====
Index: perl/lib/perl5db.pl
--- perl/lib/perl5db.pl#126~29723~ 2007-01-08 13:20:26.000000000 -0800
+++ perl/lib/perl5db.pl 2007-02-15 01:34:01.000000000 -0800
@@ -1849,7 +1849,7 @@
lock($DBGR);
my $tid;
if ($ENV{PERL5DB_THREADED}) {
- $tid = eval { "[".threads->self->tid."]" };
+ $tid = eval { "[".threads->tid."]" };
}
# Check for whether we should be running continuously or not.
@@ -4660,7 +4660,7 @@
print "threads not loaded($ENV{PERL5DB_THREADED})
please run the debugger with PERL5DB_THREADED=1 set in the
environment\n";
} else {
- my $tid = threads->self->tid;
+ my $tid = threads->tid;
print "thread id: $tid\n";
}
} ## end sub cmd_e
@@ -4682,7 +4682,7 @@
print "threads not loaded($ENV{PERL5DB_THREADED})
please run the debugger with PERL5DB_THREADED=1 set in the
environment\n";
} else {
- my $tid = threads->self->tid;
+ my $tid = threads->tid;
print "thread ids: ".join(', ',
map { ($tid == $_->tid ? '<'.$_->tid.'>' : $_->tid) }
threads->list
)."\n";
==== //depot/perl/pod/perlapi.pod#286 (text+w) ====
Index: perl/pod/perlapi.pod
--- perl/pod/perlapi.pod#285~30192~ 2007-02-10 09:22:04.000000000 -0800
+++ perl/pod/perlapi.pod 2007-02-15 01:34:01.000000000 -0800
@@ -610,7 +610,7 @@
with it we copy the stacks and the new perl interpreter is
ready to run at the exact same point as the previous one.
The pseudo-fork code uses COPY_STACKS while the
-threads->new doesn't.
+threads->create doesn't.
CLONEf_KEEP_PTR_TABLE
perl_clone keeps a ptr_table with the pointer of the old
==== //depot/perl/pod/perlxs.pod#50 (text) ====
Index: perl/pod/perlxs.pod
--- perl/pod/perlxs.pod#49~28896~ 2006-09-28 03:30:21.000000000 -0700
+++ perl/pod/perlxs.pod 2007-02-15 01:34:01.000000000 -0800
@@ -2007,7 +2007,7 @@
=item MY_CXT_CLONE
By default, when a new interpreter is created as a copy of an existing one
-(eg via C<<threads->new()>>), both interpreters share the same physical
+(eg via C<<threads->create()>>), both interpreters share the same physical
my_cxt_t structure. Calling C<MY_CXT_CLONE> (typically via the package's
C<CLONE()> function), causes a byte-for-byte copy of the structure to be
taken, and any future dMY_CXT will cause the copy to be accessed instead.
==== //depot/perl/sv.c#1367 (text) ====
Index: perl/sv.c
--- perl/sv.c#1366~30105~ 2007-02-03 07:23:52.000000000 -0800
+++ perl/sv.c 2007-02-15 01:34:01.000000000 -0800
@@ -10709,7 +10709,7 @@
with it we copy the stacks and the new perl interpreter is
ready to run at the exact same point as the previous one.
The pseudo-fork code uses COPY_STACKS while the
-threads->new doesn't.
+threads->create doesn't.
CLONEf_KEEP_PTR_TABLE
perl_clone keeps a ptr_table with the pointer of the old
==== //depot/perl/t/op/threads.t#9 (text) ====
Index: perl/t/op/threads.t
--- perl/t/op/threads.t#8~29723~ 2007-01-08 13:20:26.000000000 -0800
+++ perl/t/op/threads.t 2007-02-15 01:34:01.000000000 -0800
@@ -26,7 +26,7 @@
# Attempt to free unreferenced scalar: SV 0x40173f3c
fresh_perl_is(<<'EOI', 'ok', { }, 'delete() under threads');
use threads;
-threads->new(sub { my %h=(1,2); delete $h{1}})->join for 1..2;
+threads->create(sub { my %h=(1,2); delete $h{1}})->join for 1..2;
print "ok";
EOI
@@ -40,7 +40,7 @@
my $obj = \$data;
my $copy = $obj;
Scalar::Util::weaken($copy);
-threads->new(sub { 1 })->join for (1..1);
+threads->create(sub { 1 })->join for (1..1);
print "ok";
EOI
@@ -57,7 +57,7 @@
my $object = Foo->new;
my $ref = $object;
weaken $ref;
-threads->new(sub { $ref = $object } )->join; # $ref = $object causes problems
+threads->create(sub { $ref = $object } )->join; # $ref = $object causes
problems
print "ok";
EOI
@@ -83,7 +83,7 @@
my $nthreads = shift;
my @kids = ();
for my $i (1..$nthreads) {
- my $t = threads->new(\&do_sort_one_thread, $i);
+ my $t = threads->create(\&do_sort_one_thread, $i);
print "# parent $$: continue\n";
push(@kids, $t);
}
End of Patch.