EPICS Base  7.0.6.1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
epicsEvent.h
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2011 UChicago Argonne LLC, 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 * SPDX-License-Identifier: EPICS
7 * EPICS BASE is distributed subject to a Software License Agreement found
8 * in file LICENSE that is included with this distribution.
9 \*************************************************************************/
10 
41 #ifndef epicsEventh
42 #define epicsEventh
43 
44 #include "libComAPI.h"
45 
47 typedef struct epicsEventOSD *epicsEventId;
48 
50 typedef enum {
51  epicsEventOK = 0,
52  epicsEventWaitTimeout,
53  epicsEventError
55 
57 #define epicsEventWaitStatus epicsEventStatus
58 
59 #define epicsEventWaitOK epicsEventOK
60 
61 #define epicsEventWaitError epicsEventError
62 
64 typedef enum {
65  epicsEventEmpty,
66  epicsEventFull
68 
69 #ifdef __cplusplus
70 
79 class LIBCOM_API epicsEvent {
80 public:
84  epicsEvent ( epicsEventInitialState initial = epicsEventEmpty );
88  ~epicsEvent ();
93  void trigger ();
96  void signal () { this->trigger(); }
100  void wait ();
105  bool wait ( double timeOut );
110  bool tryWait ();
115  void show ( unsigned level ) const;
116 
117  class invalidSemaphore; /* exception payload */
118 private:
119  epicsEvent ( const epicsEvent & );
120  epicsEvent & operator = ( const epicsEvent & );
121  epicsEventId id;
122 };
123 
124 extern "C" {
125 #endif /*__cplusplus */
126 
132 LIBCOM_API epicsEventId epicsEventCreate(
133  epicsEventInitialState initialState);
134 
142  epicsEventInitialState initialState);
143 
149 LIBCOM_API void epicsEventDestroy(epicsEventId id);
150 
160  epicsEventId id);
161 
167 LIBCOM_API void epicsEventMustTrigger(epicsEventId id);
168 
173 #define epicsEventSignal(ID) epicsEventMustTrigger(ID)
174 
181  epicsEventId id);
182 
188 LIBCOM_API void epicsEventMustWait(epicsEventId id);
189 
197  epicsEventId id, double timeOut);
198 
205  epicsEventId id);
206 
212 LIBCOM_API void epicsEventShow(
213  epicsEventId id, unsigned int level);
214 
215 #ifdef __cplusplus
216 }
217 #endif /*__cplusplus */
218 
219 #include "osdEvent.h"
220 
221 #endif /* epicsEventh */
LIBCOM_API epicsEventStatus epicsEventTryWait(epicsEventId id)
Similar to wait() except that if the event is currently empty the call will return immediately with s...
LIBCOM_API epicsEventStatus epicsEventWait(epicsEventId id)
Wait for an event.
LIBCOM_API void epicsEventDestroy(epicsEventId id)
Destroy an epicsEvent and any resources it holds.
epicsEventInitialState
Possible initial states of a new epicsEvent.
Definition: epicsEvent.h:64
LIBCOM_API void epicsEventMustWait(epicsEventId id)
Wait for an event (see epicsEventWait()).
LIBCOM_API void epicsEventShow(epicsEventId id, unsigned int level)
Display information about the semaphore.
A binary semaphore.
Definition: epicsEvent.h:79
epicsEventStatus
Return status from several C API routines.
Definition: epicsEvent.h:50
void signal()
Signal is a synonym for trigger().
Definition: epicsEvent.h:96
LIBCOM_API epicsEventId epicsEventMustCreate(epicsEventInitialState initialState)
Create an epicsEvent for use from C code.
LIBCOM_API epicsEventId epicsEventCreate(epicsEventInitialState initialState)
Create an epicsEvent for use from C code, or return NULL.
LIBCOM_API epicsEventStatus epicsEventTrigger(epicsEventId id)
Trigger an event i.e. ensures the next or current call to wait completes.
LIBCOM_API epicsEventStatus epicsEventWaitWithTimeout(epicsEventId id, double timeOut)
Wait an the event or until the specified timeout period is over.
struct epicsEventOSD * epicsEventId
An identifier for an epicsEvent for use with the C API.
Definition: epicsEvent.h:47
LIBCOM_API void epicsEventMustTrigger(epicsEventId id)
Trigger an event.