This is Unofficial EPICS BASE Doxygen Site
osdEvent.c File Reference
#include <limits.h>
#include <windows.h>
#include "libComAPI.h"
#include "epicsEvent.h"
+ Include dependency graph for osdEvent.c:

Go to the source code of this file.

Classes

struct  epicsEventOSD
 

Macros

#define VC_EXTRALEAN
 
#define STRICT
 

Typedefs

typedef struct epicsEventOSD epicsEventOSD
 

Functions

LIBCOM_API epicsEventId epicsEventCreate (epicsEventInitialState initialState)
 Create an epicsEvent for use from C code, or return NULL. More...
 
LIBCOM_API void epicsEventDestroy (epicsEventId pSem)
 Destroy an epicsEvent and any resources it holds. More...
 
LIBCOM_API epicsEventStatus epicsEventTrigger (epicsEventId pSem)
 Trigger an event i.e. ensures the next or current call to wait completes. More...
 
LIBCOM_API epicsEventStatus epicsEventWait (epicsEventId pSem)
 Wait for an event. More...
 
LIBCOM_API epicsEventStatus epicsEventWaitWithTimeout (epicsEventId pSem, double timeOut)
 Wait an the event or until the specified timeout period is over. More...
 
LIBCOM_API epicsEventStatus epicsEventTryWait (epicsEventId pSem)
 Similar to wait() except that if the event is currenly empty the call will return immediately with status epicsEventWaitTimeout. More...
 
LIBCOM_API void epicsEventShow (epicsEventId id, unsigned level)
 

Macro Definition Documentation

#define STRICT

Definition at line 22 of file osdEvent.c.

#define VC_EXTRALEAN

Definition at line 21 of file osdEvent.c.

Typedef Documentation

typedef struct epicsEventOSD epicsEventOSD

Function Documentation

LIBCOM_API epicsEventId epicsEventCreate ( epicsEventInitialState  initialState)

Create an epicsEvent for use from C code, or return NULL.

Parameters
initialStateStarting state, epicsEventEmpty or epicsEventFull.
Returns
An identifier for the new event, or NULL if one not be created.

Definition at line 35 of file osdEvent.c.

37 {
38  epicsEventOSD *pSem;
39 
40  pSem = malloc ( sizeof ( *pSem ) );
41  if ( pSem ) {
42  pSem->handle = CreateEvent ( NULL, FALSE, initialState?TRUE:FALSE, NULL );
43  if ( pSem->handle == 0 ) {
44  free ( pSem );
45  pSem = 0;
46  }
47  }
48 
49  return pSem;
50 }
#define FALSE
Definition: dbDefs.h:32
#define NULL
Definition: catime.c:38
#define TRUE
Definition: dbDefs.h:27
HANDLE handle
Definition: osdEvent.c:29
LIBCOM_API void epicsEventDestroy ( epicsEventId  id)

Destroy an epicsEvent and any resources it holds.

No calls to any epicsEventWait routines can be active when this call is made.

Parameters
idThe event identifier.

Definition at line 55 of file osdEvent.c.

56 {
57  CloseHandle ( pSem->handle );
58  free ( pSem );
59 }
HANDLE handle
Definition: osdEvent.c:29
LIBCOM_API void epicsEventShow ( epicsEventId  id,
unsigned  level 
)

Definition at line 142 of file osdEvent.c.

143 {
144 }
LIBCOM_API epicsEventStatus epicsEventTrigger ( epicsEventId  id)

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
idThe event identifier.
Returns
Status indicator.

Definition at line 64 of file osdEvent.c.

65 {
66  BOOL status;
67  status = SetEvent ( pSem->handle );
68  return status ? epicsEventOK : epicsEventError;
69 }
pvd::Status status
HANDLE handle
Definition: osdEvent.c:29
LIBCOM_API epicsEventStatus epicsEventTryWait ( epicsEventId  id)

Similar to wait() except that if the event is currenly empty the call will return immediately with status epicsEventWaitTimeout.

Parameters
idThe event identifier.
Returns
Status indicator, epicsEventWaitTimeout when the event is empty.

Definition at line 123 of file osdEvent.c.

124 {
125  DWORD status;
126 
127  status = WaitForSingleObject ( pSem->handle, 0 );
128  if ( status == WAIT_OBJECT_0 ) {
129  return epicsEventOK;
130  }
131  else if ( status == WAIT_TIMEOUT ) {
132  return epicsEventWaitTimeout;
133  }
134  else {
135  return epicsEventError;
136  }
137 }
pvd::Status status
HANDLE handle
Definition: osdEvent.c:29
LIBCOM_API epicsEventStatus epicsEventWait ( epicsEventId  id)

Wait for an event.

Note
Blocks until full.
Parameters
idThe event identifier.
Returns
Status indicator.

Definition at line 74 of file osdEvent.c.

75 {
76  DWORD status;
77  status = WaitForSingleObject (pSem->handle, INFINITE);
78  if ( status == WAIT_OBJECT_0 ) {
79  return epicsEventOK;
80  }
81  else {
82  return epicsEventError;
83  }
84 }
pvd::Status status
HANDLE handle
Definition: osdEvent.c:29
LIBCOM_API epicsEventStatus epicsEventWaitWithTimeout ( epicsEventId  id,
double  timeOut 
)

Wait an the event or until the specified timeout period is over.

Note
Blocks until full or timeout.
Parameters
idThe event identifier.
timeOutThe timeout delay in seconds.
Returns
Status indicator.

Definition at line 89 of file osdEvent.c.

91 {
92  static const unsigned mSecPerSec = 1000;
93  DWORD status;
94  DWORD tmo;
95 
96  if ( timeOut <= 0.0 ) {
97  tmo = 0u;
98  }
99  else if ( timeOut >= INFINITE / mSecPerSec ) {
100  tmo = INFINITE - 1;
101  }
102  else {
103  tmo = ( DWORD ) ( ( timeOut * mSecPerSec ) + 0.5 );
104  if ( tmo == 0 ) {
105  tmo = 1;
106  }
107  }
108  status = WaitForSingleObject ( pSem->handle, tmo );
109  if ( status == WAIT_OBJECT_0 ) {
110  return epicsEventOK;
111  }
112  else if ( status == WAIT_TIMEOUT ) {
113  return epicsEventWaitTimeout;
114  }
115  else {
116  return epicsEventError;
117  }
118 }
pvd::Status status
const unsigned mSecPerSec
Definition: fdManager.cpp:34
HANDLE handle
Definition: osdEvent.c:29