ROOT-Sim core  3.0.0-rc.2
A General-Purpose Multi-threaded Parallel/Distributed Simulation Library
Functions
msg_allocator.c File Reference

Memory management functions for messages. More...

#include <mm/msg_allocator.h>
#include <core/core.h>
#include <datatypes/array.h>
#include <gvt/gvt.h>
Include dependency graph for msg_allocator.c:

Functions

static __thread dyn_array (struct lp_msg *)
 
void msg_allocator_init (void)
 Initialize the message allocator thread-local data structures.
 
void msg_allocator_fini (void)
 Finalize the message allocator thread-local data structures.
 
struct lp_msgmsg_allocator_alloc (unsigned payload_size)
 Allocate a new message with given payload size. More...
 
void msg_allocator_free (struct lp_msg *msg)
 Free a message. More...
 
void msg_allocator_free_at_gvt (struct lp_msg *msg)
 Free a message after its destination time is committed. More...
 
void msg_allocator_on_gvt (simtime_t current_gvt)
 Free the committed messages after a new GVT has been computed. More...
 
struct lp_msgmsg_allocator_pack (lp_id_t receiver, simtime_t timestamp, unsigned event_type, const void *payload, unsigned payload_size)
 Allocate a new message and populate it. More...
 

Detailed Description

Memory management functions for messages.

Memory management functions for messages

Function Documentation

◆ msg_allocator_alloc()

struct lp_msg* msg_allocator_alloc ( unsigned  payload_size)

Allocate a new message with given payload size.

Parameters
payload_sizethe size in bytes of the requested message payload
Returns
a new message with at least the requested amount of payload space

Since this module relies on the member lp_msg.pl_size (see msg_allocator_free()), it has writing responsibility on it.

◆ msg_allocator_free()

void msg_allocator_free ( struct lp_msg msg)

Free a message.

Parameters
msga pointer to the message to release

◆ msg_allocator_free_at_gvt()

void msg_allocator_free_at_gvt ( struct lp_msg msg)

Free a message after its destination time is committed.

Parameters
msga pointer to the message to release

◆ msg_allocator_on_gvt()

void msg_allocator_on_gvt ( simtime_t  current_gvt)

Free the committed messages after a new GVT has been computed.

Parameters
current_gvtthe latest value of the GVT

◆ msg_allocator_pack()

struct lp_msg* msg_allocator_pack ( lp_id_t  receiver,
simtime_t  timestamp,
unsigned  event_type,
const void *  payload,
unsigned  payload_size 
)

Allocate a new message and populate it.

Parameters
receiverthe id of the LP which must receive this message
timestampthe logical time at which this message must be processed
event_typea field which can be used by the model to distinguish them
payloadthe payload to copy into the message
payload_sizethe size in bytes of the payload to copy into the message
Returns
a new populated message