1

I have task to create messaging queue between processes that will not have size limit (up to 1 Mb, but most of messages are 128 bytes size).

So, I can't use:

  • boost::interproc::message_queue - has limited size;
  • zeromq (inproc://) - it is not implemented for Windows;
  • sockets (zeromq, or any other socket interface) - I can't occupy any port;

That is why I decide to use boost::interproc::shared_memory_object.

I plan to truncate up to 1Mb of memory, and then put there any message with header, that will defines it's size or will inform that it is last message.

Function to write - that will lock named mutex, write to the end of heap message and move "last message" flag to show it.

Function to read - that will lock it, read all and delete, moving "finish flag" to beginning of heap.

That looks good, but question is to mapping 1MB of memory each time I want to read/write. I afraid that may be long operation. Is it true?

If mapping such big heap is high cost operation, how can I solve it? Maybe there is another mechanism for interproc message queue without message size limit?

Arkady
  • 2,084
  • 3
  • 27
  • 48
  • Why don't you just send multiple messages? – nwp Jun 03 '14 at 10:48
  • Pipes can be abused as message queues. – nwp Jun 03 '14 at 10:49
  • What do you mean by "send multiple messages", using which technology? – Arkady Jun 03 '14 at 10:50
  • I didn't found implementation for pipes in boost. Which cross-platform implementation should I use, Poco? Poco pipes works very strange for me, I had bad experience... But I will look at them again, thanks. – Arkady Jun 03 '14 at 10:52
  • For example "boost::interproc::message_queue - has limited size". You can just bypass the size limit by sending multiple messages using `boost::interproc::message_queue`. – nwp Jun 03 '14 at 10:52
  • you are talking about creating cutting mechanism to split message by small parts and then agglutinate them? – Arkady Jun 03 '14 at 10:53
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/54977/discussion-between-nwp-and-arkady). – nwp Jun 03 '14 at 10:55
  • I don't think that any other ipc support upto 1mb of size except shared memory but you can use stream sockets Stream sockets You can send (by definition) an unlimited amount of data. If it cannot all be buffered or sent at once or if the receiver cannot receive it all at once, the send will either block (for blocking sockets) or return a partial count of bytes written or EAGAIN (for nonblocking sockets). – smali Jun 03 '14 at 10:58

0 Answers0