<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" 

<refentry id="mq_message_t">


<refpurpose>message data structure</refpurpose>

#include &lt;cds/msg_queue.h&gt;

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


<para>Data structure used as basic element in message queue. Pointer to
message data should be obtained by <function>get_message_data</function>.

<para>There are more possibilities how to allocate message data:
	<listitem><para>explicitly, data buffer is allocated outside of
	<structname>mq_message_t</structname> structure and only pointer to it is stored
	in this structure, see <xref linkend="create_message"/>
	<!-- - in this case the data must be deallocated explicitly--></para></listitem>
	<listitem><para>implicitly, data buffer is allocated together with
	<structname>mq_message_t</structname> structure - data must be copied into
	it after structure allocation, see <xref linkend="create_message_ex"/></para></listitem>

	<listitem><para>there is third possibility, that data and message - both -
	are allocated by caller without using
	<function>create_message</function>, <function>create_message_ex</function> and 
	<function>msg_free</function>, see <xref linkend="init_message_ex"/></para>

<para>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.

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

<refsect1><title>See Also</title>
<para><xref linkend="msg_queue_t"/>