[Petal] [PATCH] Options via constructor rather than package globals

Grant McLean grant at mclean.net.nz
Fri Jun 6 08:41:03 BST 2003


Fergal Daly wrote:
> On Thursday 05 June 2003 11:01 am, Jean-Michel Hiver wrote:
> 
>>Having the options at an object level did really involve quite a lot of
>>changes. So instead of making the rest of Petal code aware of per-object
>>options, I changed the process() method to declare the global options
>>variables as local and set them to the per-objects options.
> 
> 
> I think this pretty much guarantees that using these features with threads is 
> not safe. I'm not sure how many people will want to use Petal with threads 
> but...

I imagine that increasing usage of mod_perl 2 and Apache 2 will lead
to a lot of people using Petal with threads.

Having said that, I believe Jean-Michel is right, using globals is
not inherently thread-unsafe in Perl.  Under the original threading
modle introduced with Perl 5.005, it would have been a problem -
all variables were shared between threads by default and globals
needed to be protected with locks.  Under the new iThreads model
introduced in Perl 5.6, nothing is shared between threads unless
you share it.

It might make sense in the future for the memory caching functions
in Petal to use a shared global hash.  At that point, locking that
particular global would be necessary.

Regards
Grant





More information about the Petal mailing list