http://www.perlmonks.org?node_id=660348


in reply to Designing an enqueing application proxy

I'd say you're not far off. The biggest issue is the idea of the 'timed subroutine' to dispatch requests to the worker threads.

More easily, the worker threads can just grab another request when they have finished what they are doing (the job queue will need a mutex to avoid multiple threads messing with it at the same time).

You also only need one listener. The job of that thread is to accept evey incoming connection and put the request in the 'to be processed' queue, which the worker threads are consuming as described above.

Of course, some people prefer processes to threads, etc. And your problem is probably best solved by changes to the applications at either end. Still, I hope the above is useful.