August 2017
Intermediate to advanced
438 pages
14h 19m
English
We cannot use pointers in shared memory because, when a piece of shared memory is mapped into the address space of a process, its address is valid only for that process. When we are getting the address of a variable, it is just a local address for that process. Other processes will map shared memory to a different base address, and as a result, the variable address differs.

So, how can we work with an address that is always changing? There is a trick! As the pointer and structure are in the same shared memory segment, the distance between them does not change. The idea behind boost::interprocess::offset_ptr is to remember that ...
Read now
Unlock full access