EPICS Base  7.0.7.0
 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 ();
107  bool wait ( double timeout );
112  bool tryWait ();
117  void show ( unsigned level ) const;
118 
119  class invalidSemaphore; /* exception payload */
120 private:
121  epicsEvent ( const epicsEvent & );
122  epicsEvent & operator = ( const epicsEvent & );
123  epicsEventId id;
124 };
125 
126 extern "C" {
127 #endif /*__cplusplus */
128 
134 LIBCOM_API epicsEventId epicsEventCreate(
135  epicsEventInitialState initialState);
136 
144  epicsEventInitialState initialState);
145 
151 LIBCOM_API void epicsEventDestroy(epicsEventId id);
152 
162  epicsEventId id);
163 
169 LIBCOM_API void epicsEventMustTrigger(epicsEventId id);
170 
175 #define epicsEventSignal(ID) epicsEventMustTrigger(ID)
176 
183  epicsEventId id);
184 
190 LIBCOM_API void epicsEventMustWait(epicsEventId id);
191 
201  epicsEventId id, double timeout);
202 
209  epicsEventId id);
210 
216 LIBCOM_API void epicsEventShow(
217  epicsEventId id, unsigned int level);
218 
219 #ifdef __cplusplus
220 }
221 #endif /*__cplusplus */
222 
223 #include "osdEvent.h"
224 
225 #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 epicsEventStatus epicsEventWaitWithTimeout(epicsEventId id, double timeout)
Wait an the event or until the specified timeout period is over.
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.
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.