Hello,
I am experimenting here and I am curious about something.
Is it possible to share a variable using threads::shared between perl interpreter threads in mod_perl? These being the interpreters started when a parent starts.
Eg:
use threads::shared;
my $sharedVar = "bleh";
sub handler : method { ... }
Now, I know if I go ahead and create threads in the handler method or even a pool of global worker threads, $sharedVar is shared between the threads created. But what of the other threads that are started and sitting in the pool of interps that mod_perl creates upon startup? How can I share a variable between all of the interpreter threads? What about locking or use of semaphores or signals?
Maybe I am missing something, perhaps it's not possible.
I am hoping to use an in house class in mod_perl2 that maintains it's own threads for performing tasks. The problem is one task has to be synchronized between all threads in a whole process. Works fine under perl alone, problems arise under mod_perl+worker_mpm tho.
Everything should work identically, and you need to do locking all the same. The only thing to be aware of is that perl requires you to declare a shared variable before you spawn threads. Same goes for mod_perl - declare your shared variables at the server startup, before perl interpreters are created and you should be able to share those. I haven't tested that though. But in theory it should work. So make sure that you load that module that you quoted a part of above at the server startup and see if makes any difference. We should add a test for that.
-- __________________________________________________________________ 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
-- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html