Boost logo

Boost :

From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2006-02-07 16:15:04


Hi Fred,

> After rereading the documentation and reading the code, I think I was
> confused when I wrote this. It appears that the shared_message_queue
> cannot be used for objects created with the
> named_shared_object::construct member function. A memcpy is done on
> the buffer passed into send, so objects cannot be sent. Thus, a void*
> is correct.
>
> I do think that the documentation should be improved on that. I wasn't
> sure until I dug into the source code. If there are other places in
> the shmem library that don't support objects, I'd like to see those
> documented as well.

Surely documentation can be improved to show that shared_message_queue
is a common, byte copying message queue between processes, just like
localhost UDP socket messaging. The meaning of the bytes should be
common between applications, the queue just forwards byte packets. The
queue is an example of a higher level IPC mechanism built using Shmem
primitives (shared memory, shared memory conditions and mutexes).

You can pass structured data using shared message queue, just like the
example of the section shows. You can build all your objects in a user
buffer and byte-serialize it through the message queue. This is
different from building it in shared memory, but like using shared
memory, both processes must be ABI-compatible.

> Shmem is the first library I've seen that tries to support passing a
> C++ object through shared memory to another process. It seems like a
> really good idea, and I'd be happier if it were supported throughout
> the library. Maybe the shared_message_queue should support only
> offset_ptr's to objects that are created elsewhere in the
> named_shared_object?

I think that a message queue like this should not care about the
contained bytes. If you need a queue of objects of the same type. It's
clear that you can build a STL-like object queue above
shared_message_queue doing your casts. If that is a need, I'm ready to
implement a "shared_object_queue". But these passed objects must be
self-contained, I mean, you can pass a boost::shmem::vector<> because I
would need to know how to bye-serialize it. However, you can use
named_heap_object, construct in a single buffer all your complex data,
and byte-copy it to another process to pass all the information.

Regards,

Ion


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk