I want to store a boost::posix_time::ptime object in a Windows shared memory map for multiple processes.
However, for this to be safe, ptime cannot have pointers to other places in memory (i.e. it needs to be a POD) or else the various processes accessing the memory map will run into problems because parts of the ptime object are owned by another process.
So is ptime safe to store in a Windows shared memory map?
I ended up converting boost’s
ptimeinto microseconds based off the Unix epoch, like this:I could have easily just used
deltaTime.ticks(), but then I would also have needed to keep track ofdeltaTime.ticks_per_second(). For my case, microseconds was enough precision.