#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <pthread.h>
#include "epicsEvent.h"
#include "epicsTime.h"
#include "errlog.h"
Go to the source code of this file.
#define checkStatus |
( |
|
status, |
|
|
|
routine, |
|
|
|
func |
|
) |
| |
Value: }
#define printStatus(status, routine, func)
Definition at line 35 of file osdEvent.c.
#define checkStatusReturn |
( |
|
status, |
|
|
|
routine, |
|
|
|
func |
|
) |
| |
Value: }
#define printStatus(status, routine, func)
Definition at line 40 of file osdEvent.c.
Create an epicsEvent for use from C code, or return NULL.
- Parameters
-
initialState | Starting state, epicsEventEmpty or epicsEventFull . |
- Returns
- An identifier for the new event, or NULL if one not be created.
Definition at line 47 of file osdEvent.c.
56 printStatus(status,
"pthread_mutex_init",
"epicsEventCreate");
58 status = pthread_cond_init(&pevent->
cond, 0);
61 printStatus(status,
"pthread_cond_init",
"epicsEventCreate");
62 status = pthread_mutex_destroy(&pevent->
mutex);
63 checkStatus(status,
"pthread_mutex_destroy",
"epicsEventCreate");
#define checkStatus(status, routine, func)
#define printStatus(status, routine, func)
Destroy an epicsEvent and any resources it holds.
No calls to any epicsEventWait routines can be active when this call is made.
- Parameters
-
Definition at line 70 of file osdEvent.c.
74 checkStatus(status,
"pthread_mutex_destroy",
"epicsEventDestroy");
75 status = pthread_cond_destroy(&pevent->
cond);
76 checkStatus(status,
"pthread_cond_destroy",
"epicsEventDestroy");
#define checkStatus(status, routine, func)
LIBCOM_API void epicsEventShow |
( |
epicsEventId |
id, |
|
|
unsigned int |
level |
|
) |
| |
Display information about the semaphore.
- Note
- The information displayed is architecture dependant.
- Parameters
-
id | The event identifier. |
level | An unsigned int for the level of information to be displayed. |
Definition at line 150 of file osdEvent.c.
152 printf(
"epicsEvent %p: %s\n", pevent,
153 pevent->
isFull ?
"full" :
"empty");
155 printf(
" pthread_mutex = %p, pthread_cond = %p\n",
Trigger an event i.e. ensures the next or current call to wait completes.
- Note
- This method may be called from a VxWorks or RTEMS interrupt handler.
- Parameters
-
- Returns
- Status indicator.
Definition at line 80 of file osdEvent.c.
87 status = pthread_cond_signal(&pevent->
cond);
88 checkStatus(status,
"pthread_cond_signal",
"epicsEventTrigger");
90 status = pthread_mutex_unlock(&pevent->
mutex);
#define checkStatusReturn(status, routine, func)
#define checkStatus(status, routine, func)
Similar to wait() except that if the event is currenly empty the call will return immediately with status epicsEventWaitTimeout
.
- Parameters
-
- Returns
- Status indicator,
epicsEventWaitTimeout
when the event is empty.
Definition at line 145 of file osdEvent.c.
LIBCOM_API epicsEventStatus epicsEventWaitWithTimeout(epicsEventId pevent, double timeout)
Wait an the event or until the specified timeout period is over.
Wait for an event.
- Note
- Blocks until full.
- Parameters
-
- Returns
- Status indicator.
Definition at line 95 of file osdEvent.c.
102 status = pthread_cond_wait(&pevent->
cond, &pevent->
mutex);
104 printStatus(status,
"pthread_cond_wait",
"epicsEventWait");
112 status = pthread_mutex_unlock(&pevent->
mutex);
#define checkStatusReturn(status, routine, func)
#define printStatus(status, routine, func)
epicsEventStatus
Return status from several C API routines.
Wait an the event or until the specified timeout period is over.
- Note
- Blocks until full or timeout.
- Parameters
-
id | The event identifier. |
timeOut | The timeout delay in seconds. |
- Returns
- Status indicator.
Definition at line 117 of file osdEvent.c.
128 while (!status && !pevent->
isFull) {
129 status = pthread_cond_timedwait(&pevent->
cond, &pevent->
mutex,
133 result = (status == ETIMEDOUT) ?
140 status = pthread_mutex_unlock(&pevent->
mutex);
LIBCOM_API void convertDoubleToWakeTime(double timeout, struct timespec *wakeTime)
#define checkStatusReturn(status, routine, func)
epicsEventStatus
Return status from several C API routines.
Defined by POSIX Real Time.