If it were my program (and if there were a reasonable number of child processes), I might instead use one pipe for every child, put them in a queue, and shift/push to send a task. Of course, that assumes that all of the jobs take about the same amount of time. If that's not the case, the child could write to the pipe when it finishes and only then could the parent push the pipe back on to the queue.
I don't think you can avoid some sort of locking if you have multiple processes contending for a single shared resource.
In reply to Re: Tasking children from a single pipe
by chromatic
in thread Tasking children from a single pipe
by vancetech
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |