I tried to figure out how to do memory mapping with Boost once... It was complicated. I wish there was a good crossplatform solution that was clear and easy to use
Are you talking about just mapping a file into memory? Because there are only two function calls you need to do something like that in POSIX:
open(), and then mmap().
If you're talking about POSIX shared memory, you can do that with shm_open(). The only thing you have to do is have both processes use the same name for the shared memory area. Additionally, you can use POSIX named semaphores as a synchronization primitive.
It's pretty easy to wrap these functions up in a C++ class. You could conceivably share an entire C++ class between two processes using these primitives.
"You could conceivably share an entire C++ class between two processes using these primitives."
Not really. May be just memory mapping a plain class/struct, without virtual function tables, etc. (pointers are not necessarily valid from process to process)
The crazy thing is that it isn't that difficult to do. Just like thread local allocation, the easiest way seems to be to just figure out the systems calls yourself and wrap them up. All the solutions out there seem WAY over complicated.
The best solution I've found is whitedb, although it does leave something to be desired. The biggest flaw is that it is GPL, which is not a good license for something meant to be included as source. It also isn't thread safe without locking everything.
open(), and then mmap().
If you're talking about POSIX shared memory, you can do that with shm_open(). The only thing you have to do is have both processes use the same name for the shared memory area. Additionally, you can use POSIX named semaphores as a synchronization primitive.
It's pretty easy to wrap these functions up in a C++ class. You could conceivably share an entire C++ class between two processes using these primitives.