diff options
author | Jerry D. Hedden <jdhedden@cpan.org> | 2007-02-12 04:04:33 -0800 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2007-02-15 09:34:01 +0000 |
commit | 878090d5582120ef9336936d4fc06895b4fd242a (patch) | |
tree | b937d124e5c21f6581ac096678f212c38b29f246 | |
parent | e9950d3b0610b91bb9d19cb0918fe7e81505fd79 (diff) | |
download | perl-878090d5582120ef9336936d4fc06895b4fd242a.tar.gz |
Use newer 'threads' constructs
From: "Jerry D. Hedden" <jdhedden@yahoo.com>
Message-ID: <844555.64815.qm@web30202.mail.mud.yahoo.com>
p4raw-id: //depot/perl@30310
-rw-r--r-- | ext/XS/APItest/t/my_cxt.t | 2 | ||||
-rw-r--r-- | ext/threads/shared/t/blessed.t | 4 | ||||
-rw-r--r-- | ext/threads/shared/t/cond.t | 8 | ||||
-rw-r--r-- | ext/threads/shared/t/hv_refs.t | 2 | ||||
-rwxr-xr-x | ext/threads/threads.xs | 2 | ||||
-rw-r--r-- | lib/Thread/Queue.t | 4 | ||||
-rw-r--r-- | lib/perl5db.pl | 6 | ||||
-rw-r--r-- | pod/perlapi.pod | 2 | ||||
-rw-r--r-- | pod/perlxs.pod | 2 | ||||
-rw-r--r-- | sv.c | 2 | ||||
-rw-r--r-- | t/op/threads.t | 8 |
11 files changed, 21 insertions, 21 deletions
diff --git a/ext/XS/APItest/t/my_cxt.t b/ext/XS/APItest/t/my_cxt.t index 0b1c371f28..2c3479467a 100644 --- a/ext/XS/APItest/t/my_cxt.t +++ b/ext/XS/APItest/t/my_cxt.t @@ -50,7 +50,7 @@ sub do_thread { 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"); diff --git a/ext/threads/shared/t/blessed.t b/ext/threads/shared/t/blessed.t index 157bb53dcb..9938ad0259 100644 --- a/ext/threads/shared/t/blessed.t +++ b/ext/threads/shared/t/blessed.t @@ -48,7 +48,7 @@ my $sref = \do{ my $x }; share($sref); $sobj = $sref; -threads->new(sub { +threads->create(sub { # Bless objects bless $hobj, 'foo'; bless $aobj, 'bar'; @@ -99,7 +99,7 @@ ok(23, ref($$hobj{'array'}) eq 'yang', "blessed array in hash"); 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'; diff --git a/ext/threads/shared/t/cond.t b/ext/threads/shared/t/cond.t index 08b2d30821..7f18950a9c 100644 --- a/ext/threads/shared/t/cond.t +++ b/ext/threads/shared/t/cond.t @@ -212,7 +212,7 @@ $Base++; 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 @@ $Base++; $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 @@ $Base++; 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 @@ $Base++; $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; diff --git a/ext/threads/shared/t/hv_refs.t b/ext/threads/shared/t/hv_refs.t index 938f7a7916..cc57a34e40 100644 --- a/ext/threads/shared/t/hv_refs.t +++ b/ext/threads/shared/t/hv_refs.t @@ -97,7 +97,7 @@ ok(10, keys %foo == 0, "And make sure we realy have deleted the values"); } { my $object : shared = &share({}); - threads->new(sub { + threads->create(sub { bless $object, 'test1'; })->join; ok(16, ref($object) eq 'test1', "blessing does work"); diff --git a/ext/threads/threads.xs b/ext/threads/threads.xs index eb96414d5c..1662ee8478 100755 --- a/ext/threads/threads.xs +++ b/ext/threads/threads.xs @@ -637,7 +637,7 @@ S_ithread_create( * 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; diff --git a/lib/Thread/Queue.t b/lib/Thread/Queue.t index 33c420b750..b0d8c0a3b8 100644 --- a/lib/Thread/Queue.t +++ b/lib/Thread/Queue.t @@ -27,7 +27,7 @@ sub ok { } sub reader { - my $tid = threads->self->tid; + my $tid = threads->tid; my $i = 0; while (1) { $i++; @@ -49,7 +49,7 @@ my $nthreads = 5; 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++) { diff --git a/lib/perl5db.pl b/lib/perl5db.pl index 1b9f376a66..9f5d3b1258 100644 --- a/lib/perl5db.pl +++ b/lib/perl5db.pl @@ -1849,7 +1849,7 @@ sub DB { 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 @@ sub cmd_e { 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 @@ sub cmd_E { 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"; diff --git a/pod/perlapi.pod b/pod/perlapi.pod index b8687945af..4ebc353db1 100644 --- a/pod/perlapi.pod +++ b/pod/perlapi.pod @@ -610,7 +610,7 @@ without it we only clone the data and zero the stacks, 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 diff --git a/pod/perlxs.pod b/pod/perlxs.pod index 6d14bae275..61e023f3a6 100644 --- a/pod/perlxs.pod +++ b/pod/perlxs.pod @@ -2007,7 +2007,7 @@ comma, i.e. C<_aMY_CXT>, C<aMY_CXT_>, C<_pMY_CXT> and C<pMY_CXT_>. =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. @@ -10709,7 +10709,7 @@ without it we only clone the data and zero the stacks, 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 diff --git a/t/op/threads.t b/t/op/threads.t index 43f6b07b68..f2b6df2758 100644 --- a/t/op/threads.t +++ b/t/op/threads.t @@ -26,7 +26,7 @@ use threads; # 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 $data = "a"; 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 @@ use Scalar::Util qw(weaken); 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 @@ sub do_sort_threads { 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); } |