我想分享横跨在使用升压进程间的结构。
我定义映射文件,因为我是有它锁定问题以空互斥,我不介意做同步自己。
什么我有,虽然是找到对象的问题。
我有以下声明:
typedef boost::interprocess::basic_managed_mapped_file
< char,
boost::interprocess::rbtree_best_fit<boost::interprocess::null_mutex_family,boost::interprocess::offset_ptr<void>>,
boost::interprocess::flat_map_index>
my_mapped_file;
在方法A,我做的:
m_managedMappedFile.reset(new my_mapped_file(bip::open_or_create, filename, filesize));
auto hdr = m_managedMappedFile->find_or_construct<Foo>(bip::unique_instance)();
auto x = m_managedMappedFile->find<Foo>(bip::unique_instance);
其中一期工程为我所期望的,例如,它找到的对象。 现在,在流程B:
m_managedMappedFile.reset(new my_mapped_file(bip::open_only, filename));
auto ret = m_managedMappedFile->find<Foo>(bip::unique_instance);
出于某种原因,查找方法返回过程B.空我知道我必须做一些愚蠢的,但不能弄明白。
任何人都可以帮忙吗?