in reply to Re^4: multi-threaded questions
in thread multi-threaded questions

I don't really know what your "example suggests", but I'll assume you mean you want a persistent daemon that spins on the tests, and fires off a msg to the subordinate threads when there's work to do. One issue: your text describes 30 master threads dispatching to 30 worker threads. Does that mean the master thread only dispatches a single worker thread, or dispatches to all 30 ? If the former, your code is OK (assuming you move the enqueue() inside the loop). If the latter, you've got some challenges, and may find Thread::Queue::Multiplex useful.

Also, while your Thread::Queue use is a convenient solution, you may find Thread::Semaphore a more "CompSci"-ish solution, and maybe apply the recent addition of inter-thread signalling, assuming you're using a shiny new version of the threads module.


Perl Contrarian & SQL fanboy