Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages | Examples

Message Queues
[Application Candies]


Detailed Description

Message Queue Support.


Functions

NUTMSGQ * NutMsgQCreate (u_char bits)
 Allocate a new message que.
int NutMsgQBroadcast (u_char id, int param, void *data)
 Send a message to all message ques.
int NutMsgQPost (NUTMSGQ *que, u_char id, int param, void *data)
 Send a message to a que and return immediately.
int NutMsgQSend (NUTMSGQ *que, u_char id, int param, void *data)
 Send a message to a que and yields so that a waiting thread can act on the message.
int NutMsgQFull (NUTMSGQ *que)
 Checks the state of a que.
HANDLE NutMsgQStartTimer (NUTMSGQ *que, u_long ms, int param, void *data, u_char flags)
 Starts a periodic or one-shot timer on the given que.
void NutMsgQStopTimer (HANDLE timer)
 Stops a timer.
int NutMsgQGetMessage (NUTMSGQ *que, NUTMSG *msg, u_long timeout)
 Gets the next message from the que.
void NutMsgQFlush (NUTMSGQ *que)
 Removes all entries from a que.

Variables

NUTMSGQ * nutMsgQue
 global list of ques
NUTMSGTMR * nutMsgFreeTimers


Function Documentation

NUTMSGQ* NutMsgQCreate u_char  bits  ) 
 

Allocate a new message que.

Parameters:
bits size of the que in bits
Returns:
Handle of the new que
Note:
que size will be 2^bits

int NutMsgQBroadcast u_char  id,
int  param,
void *  data
 

Send a message to all message ques.

Parameters:
id the id of the sent message
param the param of the sent message
data the data of the sent message
Returns:
0 if sent to all ques, < 0 if one or more ques were full

int NutMsgQPost NUTMSGQ *  que,
u_char  id,
int  param,
void *  data
 

Send a message to a que and return immediately.

Parameters:
q the que to send to
id the id of the sent message
param the param of the sent message
data the data of the sent message
Returns:
0 if sent, < 0 if the que is full

int NutMsgQSend NUTMSGQ *  que,
u_char  id,
int  param,
void *  data
 

Send a message to a que and yields so that a waiting thread can act on the message.

The sending thread should have a lower priority than the receiver thread

Parameters:
q the que to send to
id the id of the sent message
param the param of the sent message
data the data of the sent message
Returns:
0 if sent, < 0 if the que is full

int NutMsgQFull NUTMSGQ *  que  ) 
 

Checks the state of a que.

Returns:
-1 if full

HANDLE NutMsgQStartTimer NUTMSGQ *  que,
u_long  ms,
int  param,
void *  data,
u_char  flags
 

Starts a periodic or one-shot timer on the given que.

Parameters:
que the que to send to
ms timeout length of the timer
id the id of the sent message
param the param of the sent message
data the data of the sent message
flags 0 or TM_ONESHOT
Returns:
HANDLE of the new timer

void NutMsgQStopTimer HANDLE  timer  ) 
 

Stops a timer.

Parameters:
timer HANDLE of the timer to stop
Note:
You must not stop a one shot that has already expired otherwise it *could* have been reused and you will end up stopping another timer

int NutMsgQGetMessage NUTMSGQ *  que,
NUTMSG *  msg,
u_long  timeout
 

Gets the next message from the que.

Parameters:
que the que to wait on
msg pointer to memory to return data to
timeout how long to wait for a message
Returns:
-1 on timeout, 0 if message retreived


© 2000-2006 by egnite Software GmbH - visit http://www.ethernut.de/