VectorNav C Library
event.h
Go to the documentation of this file.
1 
7 #ifndef _VNEVENT_H_
8 #define _VNEVENT_H_
9 
10 #include "vn/int.h"
11 #include "vn/error.h"
12 #include "vn/bool.h"
13 
14 #ifdef _WIN32
15 
16  /* Disable some warnings for Visual Studio with -Wall. */
17  #if defined(_MSC_VER)
18  #pragma warning(push)
19  #pragma warning(disable:4668)
20  #pragma warning(disable:4820)
21  #pragma warning(disable:4255)
22  #endif
23 
24  #include <Windows.h>
25 
26  #if defined(_MSC_VER)
27  #pragma warning(pop)
28  #endif
29 
30 #endif
31 
32 #if (defined __linux__ || defined __APPLE__ || defined __CYGWIN__ || defined __QNXNTO__)
33  #include <pthread.h>
34 #endif
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
41 typedef struct
42 {
43  #ifdef _WIN32
44  HANDLE handle;
45  #elif (defined __linux__ || defined __APPLE__ || defined __CYGWIN__ || defined __QNXNTO__)
46  pthread_mutex_t mutex;
47  pthread_cond_t condition;
48  bool isTriggered;
49  #else
50  #error "Unknown System"
51  #endif
52 } VnEvent;
53 
58 VnError VnEvent_initialize(VnEvent *event);
59 
66 VnError VnEvent_wait(VnEvent *event);
67 
76 VnError VnEvent_waitUs(VnEvent *event, uint32_t timeoutUs);
77 
86 VnError VnEvent_waitMs(VnEvent *event, uint32_t timeoutMs);
87 
92 VnError VnEvent_signal(VnEvent *event);
93 
94 #ifdef __cplusplus
95 }
96 #endif
97 
98 #endif
VnError VnEvent_signal(VnEvent *event)
Signals an event.
VnError VnEvent_wait(VnEvent *event)
Causes the calling thread to wait on an event until the event is signalled.
VnError VnEvent_waitMs(VnEvent *event, uint32_t timeoutMs)
Causes the calling thread to wait on an event until the event is signalled.
Structure representing an event.
Definition: event.h:41
VnError VnEvent_initialize(VnEvent *event)
Initializes a VnEvent structure.
VnError VnEvent_waitUs(VnEvent *event, uint32_t timeoutUs)
Causes the calling thread to wait on an event until the event is signalled.