hmbdc
simplify-high-performance-messaging-programming
|
if a specific hmbdc network transport (for example tcpcast, rmcast, and rnetmap) supports message with memory attachment, the message needs to be derived from this base - as the FIRST base, so it can be handled properly by the hmbdc network transport when sending and receiving it. More...
#include <Message.hpp>
Public Member Functions | |
hasMemoryAttachment () | |
default ctor More... | |
hasMemoryAttachment (char const *fileName) | |
file mapped memory More... | |
Static Public Member Functions | |
static void | unmap (hasMemoryAttachment *) |
Public Attributes | |
union { | |
boost::interprocess::managed_shared_memory ::handle_t shmHandle | |
}; | |
uint64_t | clientData [2] = {0} |
byte size of the above | |
if a specific hmbdc network transport (for example tcpcast, rmcast, and rnetmap) supports message with memory attachment, the message needs to be derived from this base - as the FIRST base, so it can be handled properly by the hmbdc network transport when sending and receiving it.
user on the sending side cannot directly free the attachment, instead the user can provide a callback func and hmbdc will call it - the default callback function is to call free on the attachment
|
inline |
default ctor
assuming attachment will be allocated and release thru heap
|
inline |
file mapped memory
fileName | file name to map |
|
inlinestatic |
client can put in any data - it will be transferred around typically to be used to help in afterConsumedCleanupFunc.
for example, when the attached memory is managed by shared_ptr<uint_8[]>:
using SP = std::shared_ptr<uint8_t[]>; auto sp = SP(new uint8_t[a.len]); MemoryAttachment3 a3; a3.len = a.len; a3.attachment = sp.get(); new (a3.clientData) SP{sp}; a3.afterConsumedCleanupFunc = [](hasMemoryAttachment* h) { ((SP*)h->clientData)->~SP(); };
union { ... } |
pointing to a func that handles cleaning up the attachment it is automatically set, but user can change it as desire when the sending side is done with this message, user code should never explicitly call this function
boost::interprocess::managed_shared_memory ::handle_t hmbdc::app::hasMemoryAttachment::shmHandle |
pointer to the attachment bytes - see clientData data member usage if those bytes are already managed by shared_ptr mechanism