VectorNav C++ Library
thread.h
Go to the documentation of this file.
1 #ifndef _VNXPLAT_THREAD_H_
7 #define _VNXPLAT_THREAD_H_
8 
9 #include "int.h"
10 #include "export.h"
11 #include "nocopy.h"
12 
13 #if _WIN32
14 #include <Windows.h>
15 #elif __linux__ || __APPLE__ || __CYGWIN__ || __QNXNTO__
16 #include <pthread.h>
17 #include <unistd.h>
18 #else
19 #error "Unknown System"
20 #endif
21 
22 namespace vn {
23 namespace xplat {
24 
26 class vn_proglib_DLLEXPORT Thread : private util::NoCopy
27 {
28 
29  // Types //////////////////////////////////////////////////////////////////
30 
31 public:
32 
35  typedef void (*ThreadStartRoutine)(void*);
36 
37  // Constructors ///////////////////////////////////////////////////////////
38 
39 public:
40 
41  ~Thread();
42 
43 private:
44 
48  explicit Thread(ThreadStartRoutine startRoutine);
49 
50  // Public Methods /////////////////////////////////////////////////////////
51 
52 public:
53 
63  static Thread* startNew(ThreadStartRoutine startRoutine, void* routineData);
64 
69  void start(void* routineData);
70 
72  void join();
73 
77  static void sleepSec(uint32_t numOfSecsToSleep);
78 
82  static void sleepMs(uint32_t numOfMsToSleep);
83 
87  static void sleepUs(uint32_t numOfUsToSleep);
88 
92  static void sleepNs(uint32_t numOfNsToSleep);
93 
94  // Private Members ////////////////////////////////////////////////////////
95 
96 private:
97 
98  // Contains internal data, mainly stuff that is required for cross-platform
99  // support.
100  struct Impl;
101  Impl *_pimpl;
102 
103 };
104 
105 }
106 }
107 
108 #endif
Represents a cross-platform thread.
Definition: thread.h:26
Definition: mock.h:4
Identifies a derived class as being unable to be copied and prevents copy attempts.
Definition: nocopy.h:21
Definition: attitude.h:8