Elizabeth Mattijsen wrote:
At 17:23 -0800 1/20/04, Stas Bekman wrote:

Elizabeth Mattijsen wrote:

One could argue that detached threads shouldn't be counted. But, as I said, a detached thread is also yanked from existence as soon as any other thread does an exit().
Hope this explains it a bit.

Thanks, Liz. But how do we deal with this problem. Should I always finish threads programs with:


$_->join() for threads->list();

but that won't work with detached threads, since list() will return only a list of non-detached threads.

So I think we need to have a new blocking call that will prevent the main program/thread from exiting till all child threads are done.


Thread::Running solves this basically.

1 while threads->running;

Note that this module uses a method of operation that suffered in tha last Apache module discussion: it creates additional methods in the threads:: namespace ;-)

I looked at the implementation. You are such a cheater, Liz ;) But hey, it works. Very cool.


I guess I could implement this in my test script using a simple semaphore (shared variable), making sure that all callbacks pull down that semaphore just before they are done and having the main thread block till that semaphore gets to 0. e.g. your Running implementation could drop the other dependencies list and just override threads::create to wrap it in a semaphore up and down calls around the callback.

Mind you, I think this should be done in threads.xs, but I haven't build up the courage to undertake that.

It certainly should be done in threads.xs. It shouldn't be too hard to implement. The accounting data could be stored in PL_modglobal (the global hash/object per interpreter).


The bottom line is that I don't want to see that error/warning message in my programs. Ideas?


Convince p5p that there should be a blocking call until all threads have finished. I tried to convince p5p about this and associated functionality about 18 months ago (if I remember correctly). I wasn't successful.

Because perl-ithreads has lost its owner when Arthur has moved to ride the ponie and no-one has stepped up to replace him. Until this happens there is no point to talk to p5p about threads, besides core dumps, because nobody is going to work on it.


May be you should try to port your modules into XS. It isn't very complex and you can always ask p5p gurus if you have any questions. so you could start with implementing that blocking call.

BTW, IMHO, that should be called by default by the parent thread, users should need to call threads->running.

__________________________________________________________________
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