VectorNav C Library
thread.h
Go to the documentation of this file.
1 
7 #ifndef _VN_THREAD_H_
8 #define _VN_THREAD_H_
9 
10 #include "vn/error.h"
11 #include "vn/int.h"
12 
13 #ifdef _WIN32
14 
15  /* Disable some warnings for Visual Studio with -Wall. */
16  #if defined(_MSC_VER)
17  #pragma warning(push)
18  #pragma warning(disable:4668)
19  #pragma warning(disable:4820)
20  #pragma warning(disable:4255)
21  #endif
22 
23  #include <Windows.h>
24 
25  #if defined(_MSC_VER)
26  #pragma warning(pop)
27  #endif
28 
29 #endif
30 
31 #if defined __linux__ || defined __APPLE__ || defined __CYGWIN__ || defined __QNXNTO__
32  #include <pthread.h>
33 #endif
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
40 typedef struct
41 {
42  #ifdef _WIN32
43  HANDLE handle;
44  #elif defined __linux__ || defined __APPLE__ || defined __CYGWIN__ || defined __QNXNTO__
45  pthread_t handle;
46  #else
47  #error "Unknown System"
48  #endif
49 } VnThread;
50 
52 typedef void (*VnThread_StartRoutine)(void*);
53 
60 VnError VnThread_startNew(VnThread *thread, VnThread_StartRoutine startRoutine, void* routineData);
61 
66 VnError VnThread_join(VnThread *thread);
67 
71 void VnThread_sleepSec(uint32_t numOfSecsToSleep);
72 
76 void VnThread_sleepMs(uint32_t numOfMsToSleep);
77 
81 void VnThread_sleepUs(uint32_t numOfUsToSleep);
82 
83 #ifdef __cplusplus
84 }
85 #endif
86 
87 #endif
VnError VnThread_join(VnThread *thread)
Blocks the calling thread until the referenced thread finishes.
VnError VnThread_startNew(VnThread *thread, VnThread_StartRoutine startRoutine, void *routineData)
Starts a new thread immediately which calls the provided start routine.
void VnThread_sleepMs(uint32_t numOfMsToSleep)
Causes the calling thread to sleep the specified number of milliseconds.
Structure for working with threads.
Definition: thread.h:40
void VnThread_sleepUs(uint32_t numOfUsToSleep)
Causes the calling thread to sleep the specified number of microseconds.
void VnThread_sleepSec(uint32_t numOfSecsToSleep)
Causes the calling thread to sleep the specified number of seconds.
void(* VnThread_StartRoutine)(void *)
Function signature for a start routine for a thread.
Definition: thread.h:52