简体   繁体   English

boost ::进程间共享内存

[英]boost::interprocess shared memory

My environment is Windows 2008/2012 C++ VS2013. 我的环境是Windows 2008/2012 C ++ VS2013。 I want an stl map to persist afte a warm restart. 我希望stl映射在热启动后能够持久保存。 Would using boost:interprocess be a solution where the application that restarts is the server side making updates to the map and another client app would be connected to the same shared mem segment just to keep it "alive", if and when the server app crashes/restarts for any reason? 使用boost:interprocess是一种解决方案,其中重新启动的应用程序是服务器端对地图进行更新,并且如果服务器应用程序崩溃,则另一个客户端应用程序将连接到同一共享内存段,以使其保持“活动状态”。 /出于任何原因重新启动?

Yes you can do this. 是的,您可以这样做。

You can employ interprocess::shared_ptr<> to get the reference counting you suggest. 您可以使用interprocess :: shared_ptr <>来获取您建议的引用计数。

Keep in mind that mapped memory is not magically transactional so in case of hard failure there will be potential for corruption. 请记住,映射的内存不是魔术般的事务性,因此,如果发生硬故障,则可能会损坏。 Use a proper database persistence provider if you need robust state persistence. 如果需要鲁棒的状态持久性,请使用适当的数据库持久性提供程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM