use ExtUtils::testlib;
use strict;
-BEGIN { $| = 1; print "1..15\n" };
+BEGIN { $| = 1; print "1..19\n" };
use threads;
ok(14, 0 == threads->self->tid(),"Check so that tid for threads work for main thread");
ok(15, 0 == threads->tid(),"Check so that tid for threads work for main thread");
+{
+ local *CLONE = sub { ok(16, threads->tid() == 9, "Tid should be correct in the clone")};
+ threads->create(sub { ok(17, threads->tid() == 9, "And tid be 9 here too") })->join();
+}
+
+{
+
+ sub Foo::DESTROY {
+ ok(19, threads->tid() == 10, "In destroy it should be correct too" )
+ }
+ my $foo;
+ threads->create(sub { ok(18, threads->tid() == 10, "And tid be 10 here");
+ $foo = bless {}, 'Foo';
+ return undef;
+ })->join();
+
+}
1;
MUTEX_DESTROY(&thread->mutex);
PerlMemShared_free(thread);
if(destroyperl) {
+ ithread* current_thread;
+ PERL_THREAD_GETSPECIFIC(self_key,current_thread);
+ PERL_THREAD_SETSPECIFIC(self_key,thread);
perl_destruct(destroyperl);
perl_free(destroyperl);
+ PERL_THREAD_SETSPECIFIC(self_key,current_thread);
+
}
PERL_SET_CONTEXT(aTHX);
}
{
ithread* thread;
CLONE_PARAMS clone_param;
-
+ ithread* current_thread;
+ PERL_THREAD_GETSPECIFIC(self_key,current_thread);
MUTEX_LOCK(&create_destruct_mutex);
thread = PerlMemShared_malloc(sizeof(ithread));
Zero(thread,1,ithread);
*/
PerlIO_flush((PerlIO*)NULL);
-
+ PERL_THREAD_SETSPECIFIC(self_key,thread);
#ifdef WIN32
thread->interp = perl_clone(aTHX, CLONEf_KEEP_PTR_TABLE | CLONEf_CLONE_HOST);
#else
PL_ptr_table = NULL;
PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
}
-
+ PERL_THREAD_SETSPECIFIC(self_key,current_thread);
PERL_SET_CONTEXT(aTHX);
/* Start the thread */
/* sv_dup over the args */
{
+ ithread* current_thread;
AV* params = (AV*) SvRV(thread->params);
CLONE_PARAMS clone_params;
clone_params.stashes = newAV();
PL_ptr_table = ptr_table_new();
+ PERL_THREAD_GETSPECIFIC(self_key,current_thread);
+ PERL_THREAD_SETSPECIFIC(self_key,thread);
retparam = (AV*) sv_dup((SV*)params, &clone_params);
+ PERL_THREAD_SETSPECIFIC(self_key,current_thread);
SvREFCNT_dec(clone_params.stashes);
SvREFCNT_inc(retparam);
ptr_table_free(PL_ptr_table);