This is more to do with sharing in general, but I am currently using
Thread::Queue::Any so my various worker threads can read data off that
and process separate to the main thread. This is just a simple loop
like:
While($running) {
If(my(@args) = $q->dequeue_dontwait) {
&func(@args);
}
}
the module that creates and handles all this has the following
structure:
my $q = new Thread::Queue::Any;
my $running:shared = 1
&spawn_threads(); // create the worker threads
now, the threads can read the $running variable fine, and when I change
it to 0 in the main thread all threads will end, lovely. However, using
Thread::Queue::Any, Thread::Queue, or even just a shared array seems to
cause problems in that the child thread always things the array is
empty. I am probably doing something dumb, but its been annoying me for
a few days now and any help would be appreciate :)
ray