mq_message_t

3

mq_message_t

message data structure

    #include <cds/msg_queue.h>

    typedef struct _mq_message_t {
    	void *data;
    	int data_len;
    	struct _mq_message_t *next;
    	destroy_function_f destroy_function;
    	enum {
    		message_allocated_with_data,
    		message_holding_data_ptr
    	} allocation_style;
    	char data_buf[1];
    } mq_message_t;

## Description

Data structure used as basic element in message queue. Pointer to message data should be obtained by `get_message_data`.

There are more possibilities how to allocate message data:

- explicitly, data buffer is allocated outside of mq_message_t structure and only pointer to it is stored in this structure, see create_message

- implicitly, data buffer is allocated together with mq_message_t structure - data must be copied into it after structure allocation, see create_message_ex

- there is third possibility, that data and message - both - are allocated by caller without using `create_message`, `create_message_ex` and `msg_free`, see init_message_ex

More different data allocation methods are due to more efficiency - less memory allocation calls and less fragmentation in second case, but more common and may be simpler for usage in first case.

Warning: internal implementation of this structure may change, use it only through existing functions.

## See Also

msg_queue_t