Some updates from my own reading of other message on this group: I figured out how to construct a kj::ArrayPtr<word> from a raw char* pointer claimed from shared memory. Moreover, the raw buffer I get from my mmap'ed file is 64-bit aligned. So this means there should be no issues backing a MallocMessageBuilder with this memory, correct?
What still eludes me if this is an intended use case for MallocMessageBuilder, particularly since I need to ensure that the MallocMessageBuilder does not write more than the fixed size buffer I claimed, and that the MallocMessageBuilder does not take ownership of the backed memory -- i.e. does not try to deallocate it. Any suggestions on this use case? On Wednesday, January 31, 2018 at 12:44:28 AM UTC-5, Sachin Kumar wrote: > > Hi, > > I'm trying to use MallocMessageBuilder that's backed by a fixed size chunk > of mmap'ed memory. So, in pseudo-code: > > char* buf = claim_mmap_memory(1024); > ::capnp::MallocMessageBuilder message(buf); > ... build message > > The questions I have: > > 1) Am I correct in trying to do this with MallocMessageBuilder given that > the memory claimed is fixed size (1024 bytes in the above example). I can > generally assume that the message should *not* exceed 1024 -- perhaps I can > programmatically check the size used as the message is built and throw an > exception if it exceeds 1024? > > 2) Is it efficient to instance a malloc message builder like this in a > tight loop repeatedly to send many messages? > > 3) How do I convert the raw char* buffer into a kj::ArrayPtr<word> so > that I can pass into the constructor of MallocMessageBuilder? > > > Thanks, > > Sachin > > -- You received this message because you are subscribed to the Google Groups "Cap'n Proto" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. Visit this group at https://groups.google.com/group/capnproto.
