VR-Link API Documentation for DIS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vlThread.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 1992-2010 VT MAK
3 ** All rights reserved.
4 ******************************************************************************/
8 #pragma once
9 
10 #include "vlMachineTypes.h"
11 #include "vlThreadSysWrapper.h"
12 #include "vlMutex.h"
13 #include "vlSmartPointers.h"
14 
15 #ifdef DtUSE_UTILITIES_NAMESPACE
16 namespace DtUSE_UTILITIES_NAMESPACE
17 {
18 #endif
19 
20 
21 
24 class DtRunnable;
25 
29 typedef void (*DtRunnableFunction)(void*,volatile bool*);
30 
36 {
37 public:
38  DtThreadStart(DtRunnable* runnable);
39  DtThreadStart(DtRunnableFunction function,void* data);
40 
42  void execute(volatile bool* stopFlag);
43 
45  void stop();
46 
47 protected:
51 };
52 
53 typedef DtBoost::shared_ptr<DtThreadStart> DtThreadStartSP;
54 
59 {
60 public:
61 
63  static DtThreadId GetCurrentThreadHandle();
64 
65 public:
67  DtThread(DtThreadStartSP threadStart);
68 
70  virtual ~DtThread();
71 
73  virtual DtThreadStatus start();
74 
76  DtThreadStatus startInCurrentThread();
77 
81  void stop(bool blocking);
82 
86  bool hasStarted() const;
87 
90  bool isRunning() const;
91 
93  DtThreadStatus join() const;
94 
96  DtThreadHandle threadId() const { return myThreadID; }
97 
98  void run();
99 
100 protected:
101 
104  bool stopped();
105 
108 
109 private:
111  DtThread(const DtThread& orig);
112  DtThread& operator=(const DtThread& orig);
113 
114 private:
116  volatile bool myTimeToStop;
117 
119  bool myRunning;
120 
122 
125  mutable DtMutex myMutex;
126 };
127 
128 #ifdef DtUSE_UTILITIES_NAMESPACE
129 }
130 #endif
131 

Document ID: Generated on Mon Feb 6 18:36:34 EST 2017 from SVN revision 173107
Copyright © 2005-2016 VT MÄK. All Rights Reserved (www.mak.com)