
On 2/7/06, Fred Bertsch <fred.bertsch@gmail.com> wrote:
Second, there isn't as much type safety as there could be in a lot of these classes. For example, shared_message_queue does not have a template parameter to determine what is stored in the queue. Instead, its send and receive member functions take void*'s. Is there a good reason for this? I suppose another process could use the same shared_message_queue with another type, but I'd really like to see some type safety within the same process.
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. 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?