At 11:56 AM -0500 1/25/05, Eric Garland wrote: >Elizabeth Mattijsen wrote: >>You might want to have a look at Thread::Running on CPAN, by yours truly. >Interesting approach. I found an issue in that an immediate call to >running after starting a thread returns false ala: > >my $thread = threads->new( \&worker_thread ); >while ($thread->running) { > select(undef,undef,undef,0.1); > print "Still running\n"; >} > >will fall right through the while loop. Adding a yield or a pause >above the while loop seems to fix the problem. Hmmm... this caused by the fact that the thread started flag is set inside the thread, rather than by the starting thread. Seems like I need to do that in the parent thread. Good point! I'll try to fix this and post an update later tonight. >Looking through the code, the trick you use seems to be running the >entire thread in an eval so that the exit can be trapped by a >wrapper subroutine. That's great! I think I'll just use that >directly. Sure, by all means! >>>Is there a way to remove the shared variables from the join >>>threads so that they take up as little memory as possible? >>Not sure what you mean by that. >I don't really understand much about shared variable memory usage in >ithreads but it seems that when you have a shared data structure, it >takes up memory for each thread. I'm dealing with a large (100,000 >entry) multi dimensional array where each element is approximately >20 elements and several of them are arrays themselves. The process >tends to use up about 400 MB of ram when running (not all perl) and >I'm testing on a machine with 512mb of RAM. Adding the watcher >threads slowed the machine to a crawl. It may have just been the >overhead of the interpreters that did that since I'm so close to >using all my ram. I assumed that if I could remove the large shared >data structure from the watcher threads, it would make them more >memory efficient. Is that true? I think you're out of luck. See: http://perlmonks.org/index.pl?node_id=288022 . Kind regards, LizThread Previous