hmbdc
simplify-high-performance-messaging-programming
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
hmbdc::app::hasMemoryAttachment Class Reference

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>

Inheritance diagram for hmbdc::app::hasMemoryAttachment:
hmbdc::tips::hasSharedPtrAttachment< Message, T >::hmbdcSerialized

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
 

Detailed Description

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

Constructor & Destructor Documentation

◆ hasMemoryAttachment() [1/2]

hmbdc::app::hasMemoryAttachment::hasMemoryAttachment ( )
inline

default ctor

assuming attachment will be allocated and release thru heap

◆ hasMemoryAttachment() [2/2]

hmbdc::app::hasMemoryAttachment::hasMemoryAttachment ( char const *  fileName)
inline

file mapped memory

Parameters
fileNamefile name to map

Member Function Documentation

◆ unmap()

void hmbdc::app::hasMemoryAttachment::unmap ( hasMemoryAttachment a)
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(); };

Member Data Documentation

◆ @16

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

◆ shmHandle

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


The documentation for this class was generated from the following file: