I am trying to share a structure across processes using interprocess in Boost.
I've defined the mapped file to use null mutex because I was having problems with it locking and I don't mind doing the synchronisation myself.
What I am having problems with though is finding of objects.
I have the following declaration:
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;
In process A, I do:
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);
Which works as I would expect, i.e. it finds the object. Now, in process B:
m_managedMappedFile.reset(new my_mapped_file(bip::open_only, filename));
auto ret = m_managedMappedFile->find<Foo>(bip::unique_instance);
For some reason the find method returns null in process B. I realise I must be doing something daft, but can't figure it out.
Can anyone help?