develooper Front page | perl.ithreads | Postings from August 2008

Re: XS callbacks from different threads.

Thread Previous | Thread Next
From:
Shmuel Fomberg
Date:
August 7, 2008 12:04
Subject:
Re: XS callbacks from different threads.
Message ID:
489B46C5.2030506@012.net.il
Josef Wolf wrote:

>> Well, maybe, but there is already one thread that is passing through 
>> perl, so calling PERL_SET_CONTEXT for this perl on other thread is 
>> pulling the rug under the first thread's legs. it can't be good.
> I've got it working now.  The solution is to PERL_SET_CONTEXT()
> _before_ declaring the context with dTHX.  The code looks like this now:

Interesting to know that it's working. Thanks.

>>> static SV *callback_ref = (SV*)NULL;
>> Reality check: you do know that "static" means here, right?
> I think so: I have exactly one instance of this variable.  Do you see
> any problems with this?

Um, you are thinking C++. declaring static variable outside object or 
function says something about it's scope. (you still get one instance of 
this, even without the static)

>>> int call_perl (int cnt, ...)
>>> {
>>>    dTHX;
>>>    PERL_SET_CONTEXT(my_perl);
>> I hate the "my_perl" parameter. Who defined it? what is it set to? 
> AFAIK, this is created by dTHX.

Correct. but from where does the dTHX take it? from the connection 
between the thread and one perl interpreter. who makes the connection? 
PERL_SET_CONTEXT. but the PERL_SET_CONTEXT is inited with my_perl... see 
the loop here?

Shmuel.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About