ct_query_msg

The ct_query_msg function enables a thread to determine the type and length of the first message in its input queue, if any.

Prototype:

Ct_msgheader ct_query_msg( void );

Parameters:

None.

Return Value:

A small struct declared in ct.h as follows:
	typedef struct
	{
		Ct_msgtype type;
		size_t length;
	} Ct_msgheader;

Discussion:

In the returned Ct_msgheader, the type member is zero if there is no message. Otherwise it is the message type assigned by the thread that sent the message.

The len member is the length of any data associated with the message.

Note that ct_query_msg() does not fetch the associated data, nor does it dequeue the message. It merely provides preliminary information so that the thread can decide what to do next. Use ct_dequeue_msg() to fetch the data and dequeue the message, or ct_discard_msg() to discard the message without fetching its data.

Restrictions:

It is neither sensible nor useful to call ct_query_msg() except from a thread or user exit, i.e. when the scheduler is running. If you call it at any other time, it will merely report that there is no message.
Home