In the previous recipe, we saw how to create shared memory and how to place some objects in it. Now it's time to do something useful. Let's take an example from the Creating a work_queue class recipe in Chapter 5, Multithreading, and make it work for multiple processes. At the end of this example, we'll get a class that can store different tasks and pass them between processes.
This recipe uses techniques from the previous one. You will also need to read the Creating a work_queue class recipe in Chapter 5, Multithreading, and get its main idea. The example requires linking against the runtime library on some platforms.
It is considered that spawning separate subprocesses instead of threads makes a program more reliable, because termination of a subprocess won't terminate the main process. We won't argue with that assumption here, and just see how data sharing between processes can be implemented.
A lot of headers are required for...