Thread

Posted on Wed Jul 25 16:43:29 2007 by vadimlv
update some data without reloading Apache
Hi all
I try to update some data without reloading Apache (thread-based Apache model). I have Data.pm with some shared variables:
#########
package Data;
use threads;
use threads::shared;
share($test);
$test = 'str1';
share($test1);
$test1 = 'str2';

1;
#########
When I try to change some shared variable - all ok. All threads update variable value.
But when I try to create new shared variable - it's work only for one thread. The others threads don't see this new variable.
Is there any way to add shared variable without reloading Apache ?
Could anybody help me?
#########
package Update;
....
use Data;
use threads;
use threads::shared;
sub handler
{
...
# it's ok!
$Data::test1 = 'new_value';
# it's work only for one thread
share($Data::test2);
$Data::test2 = 'new_value';
...
}
#########
Direct Responses: 5811 | Write a response
Posted on Wed Jul 25 18:24:45 2007 by jdhedden in response to 5810
Re: update some data without reloading Apache
> But when I try to create new shared variable - it's
> work only for one thread. The others threads don't
> see this new variable.

Try using a shared hash, and adding new keys to it.
Direct Responses: 5813 | Write a response
Posted on Thu Jul 26 13:22:31 2007 by vadimlv in response to 5811
Re: update some data without reloading Apache
Thank you. It's work
#########
package Data;
use threads;
use threads::shared;
share(%data);
$data{'test'} = 'str1';
$data{'test1'} = 'str2';
1;
#########
#########
package Update;
....
use Data;
sub handler
{
...
# it's ok!
$Data::data{'test2'} = 'new_variable';
...
}
#########
Write a response