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");
share($sref);
$sobj = $sref;
-threads->new(sub {
+threads->create(sub {
# Bless objects
bless $hobj, 'foo';
bless $aobj, 'bar';
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';
lock($counter);
if ($n > 0) {
$counter++;
- $th = threads->new(\&broad, $n-1);
+ $th = threads->create(\&broad, $n-1);
cond_wait($counter);
$counter += 10;
}
$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;
lock($r);
if ($n > 0) {
$$r++;
- $th = threads->new(\&broad2, $n-1);
+ $th = threads->create(\&broad2, $n-1);
cond_wait($r);
$$r += 10;
}
$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;
}
{
my $object : shared = &share({});
- threads->new(sub {
+ threads->create(sub {
bless $object, 'test1';
})->join;
ok(16, ref($object) eq 'test1', "blessing does work");
* 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;
}
sub reader {
- my $tid = threads->self->tid;
+ my $tid = threads->tid;
my $i = 0;
while (1) {
$i++;
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++) {
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.
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
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";
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
=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.
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
# 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
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
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
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);
}