[InterProcess] Compatibility with Boost multi_array

Can I create Boost multi_array in shared memory using Boost.InterProcess..? Can some one explain as to how this can be done.? I tried providing the Boost InterProcess Allocator to the Boost multi_array but it gives the expected compiler error of casting an offset<ptr> to T* , when the multi_array tries to convert return type of the allocator allocate function(which is an offset<ptr>) to T*. Can this problem be overcome by writing a custom stl compatible allocator wrapper over the interprocess allocator? Regards, Sankar

sankar lingam wrote:
Can I create Boost multi_array in shared memory using Boost.InterProcess..? Can some one explain as to how this can be done.?
I tried providing the Boost InterProcess Allocator to the Boost multi_array but it gives the expected compiler error of casting an offset<ptr> to T* , when the multi_array tries to convert return type of the allocator allocate function(which is an offset<ptr>) to T*.
Can this problem be overcome by writing a custom stl compatible allocator wrapper over the interprocess allocator?
Regards, Sankar
MultiArray is not compatible with Boost.Interprocess. I've never tried that, so I can give any clue on how to solve this. It would interesting to make MultiArray compatible with non-raw pointers, but this is a issue MultiArray authors should address if they find it useful. Regards, Ion

On Tue, Mar 18, 2008 at 8:13 PM, Ion Gaztañaga
sankar lingam wrote:
Can I create Boost multi_array in shared memory using Boost.InterProcess..? Can some one explain as to how this can be done.?
I tried providing the Boost InterProcess Allocator to the Boost multi_array but it gives the expected compiler error of casting an offset<ptr> to T* , when the multi_array tries to convert return type of the allocator allocate function(which is an offset<ptr>) to T*.
Can this problem be overcome by writing a custom stl compatible allocator wrapper over the interprocess allocator?
Regards, Sankar
MultiArray is not compatible with Boost.Interprocess. I've never tried that, so I can give any clue on how to solve this. It would interesting to make MultiArray compatible with non-raw pointers, but this is a issue MultiArray authors should address if they find it useful.
Regards,
Ion _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

I made the following wrapper over the Boost.InterProcessAllocator,
#include
sankar lingam wrote:
Can I create Boost multi_array in shared memory using Boost.InterProcess..? Can some one explain as to how this can be done.?
I tried providing the Boost InterProcess Allocator to the Boost multi_array but it gives the expected compiler error of casting an offset<ptr> to T* , when the multi_array tries to convert return type of the allocator allocate function(which is an offset<ptr>) to T*.
Can this problem be overcome by writing a custom stl compatible allocator wrapper over the interprocess allocator?
Regards, Sankar
MultiArray is not compatible with Boost.Interprocess. I've never tried that, so I can give any clue on how to solve this. It would interesting to make MultiArray compatible with non-raw pointers, but this is a issue MultiArray authors should address if they find it useful.
Regards,
Ion _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

sankar lingam wrote:
I made the following wrapper over the Boost.InterProcess Allocator,
[...]
and used the shared_allocator as the allocator to Boost.multi_array and
I find it working fine. The boost multi_array allocates and deallocates the memory
through shared_allocator.
Am I doing something wrong here??Can it be used this way??
MultiArray will store a raw pointer as a member. This means that if two processes map the shared memory in different addresses, the process that didn't create the MultiArray will crash. This can only work if all processes exactly map the shared memory in the same address. MultiArray adaptation would require using allocator::pointer instead of raw pointers as member pointers. In case you find it useful, latest (SVN) Boost.Multiindex is compatible with Boost.Interprocess. Regards, Ion

Thank you very much..I could see all the processes mapping the shared memory
in the
same address and that is why my program doesnot crash..
But cant this change be requested to Boost Multi.Array?? It would be really
useful
to allocate a multi array on shared memory..Would the multi array adaptation
be
difficult for the multi array developers (i meant to change it)? or should I
raise a feature
request for the same..It would be wonderful if the feature comes along with
the
boost 1.35 release...
On Wed, Mar 19, 2008 at 2:23 PM, Ion Gaztañaga
sankar lingam wrote:
I made the following wrapper over the Boost.InterProcess Allocator,
[...]
and used the shared_allocator as the allocator to Boost.multi_array and
I find it working fine. The boost multi_array allocates and deallocates the memory
through shared_allocator.
Am I doing something wrong here??Can it be used this way??
MultiArray will store a raw pointer as a member. This means that if two processes map the shared memory in different addresses, the process that didn't create the MultiArray will crash.
This can only work if all processes exactly map the shared memory in the same address. MultiArray adaptation would require using allocator::pointer instead of raw pointers as member pointers. In case you find it useful, latest (SVN) Boost.Multiindex is compatible with Boost.Interprocess.
Regards,
Ion _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

sankar lingam wrote:
But cant this change be requested to Boost Multi.Array?? It would be really useful to allocate a multi array on shared memory..Would the multi array adaptation be difficult for the multi array developers (i meant to change it)? or should I raise a feature request for the same..
I think you should raise a feature request.
It would be wonderful if the feature comes along with the boost 1.35 release...
Too late. Boost 1.35 is in RC state :-( Regards, Ion
participants (2)
-
Ion Gaztañaga
-
sankar lingam