Re: XS callbacks from different threads.
[email protected] (Shmuel Fomberg) Thu, 07 Aug 2008 22:02:29 +0300
| Newsgroups | perl.ithreads |
|---|---|
| Message-ID | <[email protected]> |
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.