This is Unofficial EPICS BASE Doxygen Site
osdMessageQueue.cpp File Reference
#include <limits.h>
#include "epicsMessageQueue.h"
+ Include dependency graph for osdMessageQueue.cpp:

Go to the source code of this file.

Functions

int sysClkRateGet (void)
 
LIBCOM_API int epicsStdCall epicsMessageQueueSendWithTimeout (epicsMessageQueueId id, void *message, unsigned int messageSize, double timeout)
 Send a message or timeout. More...
 
LIBCOM_API int epicsStdCall epicsMessageQueueReceiveWithTimeout (epicsMessageQueueId id, void *message, unsigned int size, double timeout)
 Wait for a message to be queued. More...
 

Function Documentation

LIBCOM_API int epicsStdCall epicsMessageQueueReceiveWithTimeout ( epicsMessageQueueId  id,
void *  message,
unsigned int  size,
double  timeout 
)

Wait for a message to be queued.

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.

Definition at line 38 of file osdMessageQueue.cpp.

43 {
44  int ticks;
45 
46  if (timeout<=0.0) {
47  ticks = 0;
48  } else {
49  ticks = (int)(timeout*sysClkRateGet());
50  if(ticks<=0) ticks = 1;
51  }
52  return msgQReceive((MSG_Q_ID)id, (char *)message, size, ticks);
53 }
double timeout
Definition: pvutils.cpp:25
int sysClkRateGet(void)
LIBCOM_API int epicsStdCall epicsMessageQueueSendWithTimeout ( epicsMessageQueueId  id,
void *  message,
unsigned int  messageSize,
double  timeout 
)

Send a message or 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.

Definition at line 21 of file osdMessageQueue.cpp.

26 {
27  int ticks;
28 
29  if (timeout<=0.0) {
30  ticks = 0;
31  } else {
32  ticks = (int)(timeout*sysClkRateGet());
33  if(ticks<=0) ticks = 1;
34  }
35  return msgQSend((MSG_Q_ID)id, (char *)message, messageSize, ticks, MSG_PRI_NORMAL);
36 }
double timeout
Definition: pvutils.cpp:25
int sysClkRateGet(void)
int sysClkRateGet ( void  )