There are many good reasons to go with your decision:
- Easier to think than signals.
- He had fewer cross-platform issues.
- You already have code that works this way.
- This makes it easy to add a “graceful shutdown” mechanism if you want in the future.
... etc.
Keep in mind that if you cannot prove to yourself that the multiprocessing and basic OS primitives on each platform you care about are guaranteed to work without synchronization here, you need to put Lock or something else around every access to the shared bool. This is not very difficult, but ... as soon as you do this, using, for example, Event without a common bool can be even easier.
In any case, if one of them were your cause, I would say, excellent, do it that way. But, according to your question, you really chose this because of performance:
I feel that for all children there is less overhead to just look at one common bool than to send x the number of pigments to them
If this is your reason, you are almost certainly mistaken. Children should look at the common bool (and acquire a common lock!) Every time through a certain cycle, while the signal needs to be sent only to each child once. Thus, your overhead will almost certainly be much higher.
But in fact, I can’t imagine the overhead of sending one signal to a child process or even capturing an interprocess lock once per cycle per process, somewhere near a bottleneck in any useful program, so ... why the overhead even is the question here first? Do what makes the best sense in the easiest way.
abarnert
source share