On Thu, Aug 07, 2008 at 10:02:29PM +0300, Shmuel Fomberg wrote:

> >>>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++.

No, I'm thinking pure C here.  I don't line C++ very much.  (please
feel free to check http://yosefk.com/c++fqa/ for some reasons why
I don't like 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)

Since we were talking about threads, I assumed that your question was
about having one instance (shared by all threads) against having one
instance per thread.  I need to pass the callback reference from the
main thread to the callback thread, so having a shared variable for
this is exactly what I want.

The scope should surely be limited to my file, because I don't want to
export objects without a reason.  I still don't see any problem with
this.

> >>>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?

I agree that the dTHXa() method you mentioned is the cleaner method.
BTW: I can't find any reference of this macro in the documentation. Are
you sure this is officially part of the API?

Reply via email to