If you possibly can help it, don't use shared memory for IPC. Doing it properly requires complex logic involving mutexes and such. Thread-safe queues such as
Thread::Queue are very readily available and far easier to manage. It is also much easier to test such logic and to determine that it actually works under production-level load.