in reply to Re: fork always 'n' processes.
in thread fork always 'n' processes.

Thanks for answering. 1. I have a queue of tasks, a socket is giving me; 2. I would like to process these tasks 'n' processes at a time; 3. Always 'n' processes should be active and running; 4. Until the end of the queue has been reached. I am thinking of a 'scalable' way and use more clients to process the tasks queue. TheMagician

Replies are listed 'Best First'.
Re^3: fork always $n processes
by hippo (Archbishop) on Mar 20, 2018 at 16:55 UTC

    Have you looked at Parallel::ForkManager?

    Edit: changed title because "always 'n' processes" reads too much like "Guns 'n' Roses" or "fish 'n' chips" to me.

Re^3: fork always 'n' processes.
by Anonymous Monk on Mar 20, 2018 at 17:06 UTC

    You should elaborate on your requirements. Is this intended to be portable? Windows/linux? Do you need it as perl code? There are utilities that can help in running parallel tasks (e.g. xargs). Do you need those jobs as separate processes; perhaps a threaded version might suit you as well?

    Have you searched for modules (e.g. Parallel::ForkManager)? Do you actually need a robust, efficient solution or is this homework?