#include <epicsMessageQueue.h>
|
| epicsMessageQueue (unsigned int capacity, unsigned int maximumMessageSize) |
| Constructor. More...
|
|
| ~epicsMessageQueue () |
| Destructor.
|
|
int | trySend (void *message, unsigned int messageSize) |
| Try to send a message. More...
|
|
int | send (void *message, unsigned int messageSize) |
| Send a message. More...
|
|
int | send (void *message, unsigned int messageSize, double timeout) |
| Send a message or timeout. More...
|
|
int | tryReceive (void *message, unsigned int size) |
| Try to receive a message. More...
|
|
int | receive (void *message, unsigned int size) |
| Fetch the next message on the queue. More...
|
|
int | receive (void *message, unsigned int size, double timeout) |
| Wait for and fetch the next message. More...
|
|
void | show (unsigned int level=0) |
| Displays some information about the message queue. More...
|
|
unsigned int | pending () |
| How many messages are queued. More...
|
|
Provides methods for sending messages between threads on a first in, first out basis. It is designed so that a single message queue can be used with multiple writer and reader threads.
A C++ epicsMessageQueue cannot be assigned to, copy-constructed, or constructed without giving the capacity and max-imumMessageSize arguments.
The C++ compiler will object to some of the statements below:
Definition at line 48 of file epicsMessageQueue.h.
epicsMessageQueue::epicsMessageQueue |
( |
unsigned int |
capacity, |
|
|
unsigned int |
maximumMessageSize |
|
) |
| |
- Parameters
-
capacity | Maximum number of messages to queue |
maximumMessageSize | Number of bytes of the largest message that may be queued |
int epicsMessageQueue::trySend |
( |
void * |
message, |
|
|
unsigned int |
messageSize |
|
) |
| |
- Note
- On VxWorks and RTEMS this method 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.
int epicsMessageQueue::send |
( |
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.
int epicsMessageQueue::send |
( |
void * |
message, |
|
|
unsigned int |
messageSize, |
|
|
double |
timeout |
|
) |
| |
- Parameters
-
message | Pointer to the message to be sent |
messageSize | The size of message |
timeout | The timeout delay in seconds. A timeout of zero is equivalent to calling trySend(); NaN or any value too large to be represented to the target OS is equivalent to no 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.
int epicsMessageQueue::tryReceive |
( |
void * |
message, |
|
|
unsigned int |
size |
|
) |
| |
- Parameters
-
[out] | message | Output buffer to store the received message |
| size | Size of the buffer pointed to by message |
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.
int epicsMessageQueue::receive |
( |
void * |
message, |
|
|
unsigned int |
size |
|
) |
| |
- Parameters
-
[out] | message | Output buffer to store the received message |
| size | Size of the buffer pointed to by message |
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.
int epicsMessageQueue::receive |
( |
void * |
message, |
|
|
unsigned int |
size, |
|
|
double |
timeout |
|
) |
| |
- Parameters
-
[out] | message | Output buffer to store the received message |
| size | Size of the buffer pointed to by message |
| timeout | The timeout delay in seconds. A timeout of zero is equivalent to calling tryReceive(); NaN or any value too large to be represented to the target OS is equivalent to no timeout. |
Waits up to timeout
seconds for a message to arrive if the queue is empty, then moves the first message to the message buffer.
If the received message is larger than the 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.
void epicsMessageQueue::show |
( |
unsigned int |
level = 0 | ) |
|
- Parameters
-
level | Controls the amount of information displayed. |
unsigned int epicsMessageQueue::pending |
( |
| ) |
|
- Returns
- The number of messages presently in the queue.
The documentation for this class was generated from the following file: