Joe Schaefer wrote:
Stas Bekman <[EMAIL PROTECTED]> writes:


Joe Schaefer wrote:


[...]


Obviously I don't see why that is so.  In fact, I see that it is
already implemented in parts of mod_perl, for instance when
registering a pool-cleanup callback:


$sp->cleanup_register(sub { print @{ $_[0] || [] } }, [1..3]);


Here the currently active interpreter has its refcount incremented
by mpxs_apr_pool_cleanup_register(). AFAICT the interpreter is not
allowed to reenter the thread pool until this cleanup has run. I
don't see how PerlInterpScope influences this behavior at all.
I still believe that this is the right approach, and again I wonder
why this cannot also be used in the situations you cited earlier in
this thread.

Anti-Example 1: parent interpreter compiles the anon-sub, which interpreter are you going to stick to that anon-sub?


A: As I stated, I expect the intepreter which invokes cleanup_register()
   to also be the one which executes the anonymous sub during $sp's pool
   cleanup.  Are you saying that doesn't work if the interpreter is actually
   a clone, and not the parent?

I think what happens is this:

If the (very top) parent perl interpreter is attached to the cleanup hook (which only makes sense for cleanup callbacks registered at the server startup), there is no problem, since when those callbacks are called, there are no more threads and all the calls will be serialized and that interpreter will never be used at the same time by two threads (since there are no threads on shutdown).

but you can't stick that very top parent perl interpreter to an anon-sub, because it's not thread safe. If you did, several threads may try to use the same interpreter at the same time at run time. Moreover you aren't even allowed to use that very top parent interpreter, nowhere but at the startup and shutdown.

I hope that answers the question. I'm not sure why you are asking about the clone, when there is already a problem with the top-level perl, in the simplest case where there are no clones.

Bear in mind I'm learning about threads|ithreads as I go here, so please
don't intrepret my inquisitiveness as anything other than naivete. I'm just trying to sort all this out so I can write a few useful patches.

No problem, Joe. Just ask questions and I'll try to answer them :)

As I slowly digest the rest of your post, it looks like I'll derive the most benefit from it by writing a few tests first. :-)

Yup, that's the best thing to do :)


-- __________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to