return unless($_[0] eq "threads::shared");
foreach my $ptr (keys %shared) {
if($ptr) {
- thrcnt_inc($shared{$ptr});
+ thrcnt_inc($shared{$ptr},$threads::origthread);
}
}
}
void
-thrcnt_inc(ref)
+thrcnt_inc(ref,perl)
SV* ref
+ SV* perl
CODE:
shared_sv* shared;
+ PerlInterpreter* origperl = (PerlInterpreter*) SvIV(perl);
+ PerlInterpreter* oldperl = PERL_GET_CONTEXT;
if(SvROK(ref))
ref = SvRV(ref);
shared = Perl_sharedsv_find(aTHX, ref);
if(!shared)
croak("thrcnt can only be used on shared values");
+ PERL_SET_CONTEXT(origperl);
Perl_sharedsv_thrcnt_inc(aTHX_ shared);
+ PERL_SET_CONTEXT(oldperl);
void
_thrcnt_dec(ref)
init_function = NULL;
temp_store = NULL;
+ temp_store = Perl_get_sv(current_perl, "threads::origthread", TRUE | GV_ADDMULTI);
+ sv_setiv(temp_store,(IV)current_perl);
+ temp_store = NULL;
+
+
#ifdef WIN32
thread->interp = perl_clone(current_perl, 4);
#else
thread->params = newSVsv(Perl_get_sv(thread->interp,
"threads::paramtempstore",FALSE));
+
+
/*
* And here we make sure we clean up the data we put in the
* namespace of iThread, both in the new and the calling