On Tuesday, 02 August 2011 20:24:46 Fred Moyer wrote:
> I haven't used the worker mpm, but it looks like you might want to
> preload your handler in the httpd parent process.

Unlikely that that will help. threads::shared works by creating a 
separate perl interpreter to keep the shared values. That interpreter 
does not execute any program. It simply serves as shared storage. When a 
variable is then marked as shared it is assigned magic to have the normal 
accessor methods use the storage in the other interpreter. So, no matter 
when the variable or the interpreter executing a program is created 
shared variables are always fetched from the special storage interpreter.

The special storage interpreter is a global variable at C-level.

t/response/TestPerl/ithreads.pm in the modperl test suite exercises 
shared variables. I'd take this as a starting point. First, I'd create a 
simple shared scalar as a global counter. If that works (which I think it 
does) the rest is how to use threads::shared correctly.

As for your code I think you could try to push shared apples like this

  push(@fruits,share('apple'));

Perhaps even

  push(@fruits,share(do {my $x='apple'}));

Torsten Förtsch

-- 
Need professional modperl support? Hire me! (http://foertsch.name)

Like fantasy? http://kabatinte.net

Reply via email to