
On Fri, Jan 25, 2013 at 11:49 PM, Ion Gaztañaga <igaztanaga@gmail.com> wrote:
El 25/01/2013 21:47, Matias Capeletto escribió:
But still when users will select an interprocess allocator they will be paying for every call to the views:
left_type& left = bm.left; left.size(); // needs to use offset_ptr
Have this problem also with iterators. Containers with interprocess allocators will return an iterator that can be placed in shared memory (contains offset_ptr) but when you use it to iterate in your process, you pay the price of offset_ptr. I think multiindex also pays this price.
Ok, that is interesting. Maybe I should just use offset_ptr then, if every time I iterate over the container I am using them anyways.
What MultiIndex is doing is creating the index views with a pointer to (this) every time the user ask them. I could do the same if I deprecate .left and .right and include get_left() and get_right() functions. But as I said I will like to keep the current interface... is something like the rewire extension impossible? (I am afraid it is if you are pointing to read only memory).
I don't fully understand what do you achieve with "rewire", can you elaborate, please?
Maybe you do not understand this because is a crazy idea in the context of Interprocess. I looked at your code and in the segment_manager, before you return the user the found Bimap* I wanted a user extension point to be called on the pointer: if( t_ret ) rewire_after_loading_from_shared_memory( t_ret ); return std::pair<T*, size_type>(t_ret ,sz); And I will do something like (this function being a friend of the views): template<class L, class R> void rewire_after_loading_from_shared_memory(bimap<L,R>* t) { t->left.rewire(t); t->right.rewire(t); } In left_type and right_type private section: void rewire(Core* c) { if(core!=c) core=c; } Event if this could work, the question will be if we want to allow users to place views in shared memory. For Bimap, I think it doesn't make sense... you should always stored the bimap and then get the views. But now I looked better at MultiIndex implementation and it is actually pushing the index as part of the main container hierarchy using CRTP to access the core, something I thought about yesterday also. I think I will end up doing the same for Bimap then. Thanks, Best Matias