EPICS Base  7.0.6.1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Classes | Typedefs | Functions
epicsMessageQueue.h File Reference

A C++ and a C facility for communication between threads. More...

#include "epicsAssert.h"
#include "libComAPI.h"
#include "osdMessageQueue.h"
Include dependency graph for epicsMessageQueue.h:

Go to the source code of this file.

Classes

class  epicsMessageQueue
 

Typedefs

typedef struct
epicsMessageQueueOSD * 
epicsMessageQueueId
 

Functions

LIBCOM_API epicsMessageQueueId
epicsStdCall 
epicsMessageQueueCreate (unsigned int capacity, unsigned int maximumMessageSize)
 Create a message queue. More...
 
LIBCOM_API void epicsStdCall epicsMessageQueueDestroy (epicsMessageQueueId id)
 Destroy a message queue, release all its memory.
 
LIBCOM_API int epicsStdCall epicsMessageQueueTrySend (epicsMessageQueueId id, void *message, unsigned int messageSize)
 Try to send a message. More...
 
LIBCOM_API int epicsStdCall epicsMessageQueueSend (epicsMessageQueueId id, void *message, unsigned int messageSize)
 Send a message. More...
 
LIBCOM_API int epicsStdCall epicsMessageQueueSendWithTimeout (epicsMessageQueueId id, void *message, unsigned int messageSize, double timeout)
 Send a message or timeout. More...
 
LIBCOM_API int epicsStdCall epicsMessageQueueTryReceive (epicsMessageQueueId id, void *message, unsigned int size)
 Try to receive a message. More...
 
LIBCOM_API int epicsStdCall epicsMessageQueueReceive (epicsMessageQueueId id, void *message, unsigned int size)
 Fetch the next message on the queue. More...
 
LIBCOM_API int epicsStdCall epicsMessageQueueReceiveWithTimeout (epicsMessageQueueId id, void *message, unsigned int size, double timeout)
 Wait for a message to be queued. More...
 
LIBCOM_API int epicsStdCall epicsMessageQueuePending (epicsMessageQueueId id)
 How many messages are queued. More...
 
LIBCOM_API void epicsStdCall epicsMessageQueueShow (epicsMessageQueueId id, int level)
 Displays some information about the message queue. More...
 

Detailed Description

Author
W. Eric Norum

Each C function corresponds to one of the C++ methods.

Definition in file epicsMessageQueue.h.

Function Documentation

LIBCOM_API epicsMessageQueueId epicsStdCall epicsMessageQueueCreate ( unsigned int  capacity,
unsigned int  maximumMessageSize 
)
Parameters
capacityMaximum number of messages to queue
maximumMessageSizeNumber of bytes of the largest message that may be queued
Returns
An identifier for the new queue, or 0.
LIBCOM_API int epicsStdCall epicsMessageQueueTrySend ( epicsMessageQueueId  id,
void *  message,
unsigned int  messageSize 
)
Note
On VxWorks and RTEMS this routine may be called from an interrupt handler.
Returns
0 if the message was sent to a receiver or queued for future delivery.
-1 if no more messages can be queued or if the message is larger than the queue's maximum message size.
LIBCOM_API int epicsStdCall epicsMessageQueueSend ( epicsMessageQueueId  id,
void *  message,
unsigned int  messageSize 
)
Returns
0 if the message was sent to a receiver or queued for future delivery.
-1 if the message is larger than the queue's maximum message size.
LIBCOM_API int epicsStdCall epicsMessageQueueSendWithTimeout ( epicsMessageQueueId  id,
void *  message,
unsigned int  messageSize,
double  timeout 
)
Returns
0 if the message was sent to a receiver or queued for future delivery.
-1 if the timeout was reached before the message could be sent or queued, or if the message is larger than the queue's maximum message size.
LIBCOM_API int epicsStdCall epicsMessageQueueTryReceive ( epicsMessageQueueId  id,
void *  message,
unsigned int  size 
)

If the queue holds at least one message, the first message on the queue is moved to the specified location and the length of that message is returned.

If the received message is larger than the specified message size the implementation may either return -1, or truncate the message. It is most efficient if the messageBufferSize is equal to the maximumMessageSize with which the message queue was created.

Returns
Number of bytes in the message.
-1 if the message queue is empty, or the buffer too small.
LIBCOM_API int epicsStdCall epicsMessageQueueReceive ( epicsMessageQueueId  id,
void *  message,
unsigned int  size 
)

Wait for a message to be sent if the queue is empty, then move the first message queued to the specified location.

If the received message is larger than the specified message size the implementation may either return -1, or truncate the message. It is most efficient if the messageBufferSize is equal to the maximumMessageSize with which the message queue was created.

Returns
Number of bytes in the message.
-1 if the buffer is too small for the message.
LIBCOM_API int epicsStdCall epicsMessageQueueReceiveWithTimeout ( epicsMessageQueueId  id,
void *  message,
unsigned int  size,
double  timeout 
)

Wait up to timeout seconds for a message to be sent if the queue is empty, then move the first message to the specified location.

If the received message is larger than the specified message buffer size the implementation may either return -1, or truncate the message. It is most efficient if the messageBufferSize is equal to the maximumMessageSize with which the message queue was created.

Returns
Number of bytes in the message.
-1 if a message is not received within the timeout interval.
LIBCOM_API int epicsStdCall epicsMessageQueuePending ( epicsMessageQueueId  id)
Parameters
idMessage queue identifier.
Returns
The number of messages presently in the queue.
LIBCOM_API void epicsStdCall epicsMessageQueueShow ( epicsMessageQueueId  id,
int  level 
)
Parameters
idMessage queue identifier.
levelControls the amount of information displayed.