Elizabeth Mattijsen wrote:
On Mar 23, 2010, at 6:00 AM, Ajeet Kumar wrote:
I want to share variable among threads, where threads are created using  fork, 
not using ithreads.So, How to move with it? I had tried the following :-

1.) Declared a variable in main process
2.) taken it's reference in main process
3.) Now, as because the reference is available two all of my threads, I tried 
to change the value of my variable using the reference.
4.) However, changes done by the thread is only reflected to that particular 
thread only, not to other thread and even not in the main process.

Please, give any solution, without using any ithreads or any other thread 
model.(I don't want to rebuild the perl interpreter)


You might want to look into POE::Wheel::Run combined with POE::Filter::Reference...as an example check out this from the cookbook:

http://poe.perl.org/?POE_Cookbook/Child_Processes_4

POE should help with the mgmt of the forks and the IPC between them. If that example seems to provide some assistance then definitely do more research on POE, the learning curve is pretty steep but I found it well worth it in the end.

Use forks.  Have you *looked* at forks?  Do you read what people tell you?  Do 
you read the documentation?

Otherwise, if forks doesn't do it for you: don't use Perl, use C.


Liz

--
Brian J. Miller
End Point Corp.
http://www.endpoint.com/
br...@endpoint.com

Reply via email to