This is Unofficial EPICS BASE Doxygen Site
osdMessageQueue.cpp
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2002 The University of Chicago, as Operator of Argonne
3 * National Laboratory.
4 * Copyright (c) 2002 The Regents of the University of California, as
5 * Operator of Los Alamos National Laboratory.
6 * EPICS BASE Versions 3.13.7
7 * and higher are distributed subject to a Software License Agreement found
8 * in file LICENSE that is included with this distribution.
9 \*************************************************************************/
10 /*
11  * Author W. Eric Norum
12  * norume@aps.anl.gov
13  * 630 252 4793
14  */
15 
16 #include <limits.h>
17 #include "epicsMessageQueue.h"
18 
19 extern "C" int sysClkRateGet(void);
20 
21 LIBCOM_API int epicsStdCall epicsMessageQueueSendWithTimeout(
23  void *message,
24  unsigned int messageSize,
25  double timeout)
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 }
37 
38 LIBCOM_API int epicsStdCall epicsMessageQueueReceiveWithTimeout(
40  void *message,
41  unsigned int size,
42  double timeout)
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
LIBCOM_API int epicsStdCall epicsMessageQueueSendWithTimeout(epicsMessageQueueId pmsg, void *message, unsigned int size, double timeout)
Send a message or timeout.
A C++ and a C facility for communication between threads.
int sysClkRateGet(void)
LIBCOM_API int epicsStdCall epicsMessageQueueReceiveWithTimeout(epicsMessageQueueId pmsg, void *message, unsigned int size, double timeout)
Wait for a message to be queued.
unsigned int size