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 
This file contains the declaration of DtMutex.
DtThreadStatus
Definition: vlThreadSysWrapper.h:18
DtRunnableFunction myRunnableFunction
Definition: vlThread.h:49
Includes Boost smart pointers and aliases the Boost namespace.
volatile bool myTimeToStop
Stop Flag.
Definition: vlThread.h:116
DtThreadId DtThreadHandle
Thread Handle is a windows specific device, pthreads uses the threadId for the same purposes...
Definition: vlThreadSysWrapper.h:78
DtThreadStartSP myThreadStart
Definition: vlThread.h:121
pthread_t DtThreadId
Definition: vlThreadSysWrapper.h:75
DtBoost::shared_ptr< DtThreadStart > DtThreadStartSP
Definition: vlThread.h:53
DtThreadHandle myThreadID
System Independent Thread Handle.
Definition: vlThread.h:107
This file contains wrappers for system thread calls.
instances of DtMutex are used to provide a platform independent mutual exclusion mechanism ...
Definition: vlMutex.h:31
DtThreadHandle threadId() const
Get the thread&#39;s ID.
Definition: vlThread.h:96
void * myInitializationData
Definition: vlThread.h:50
DtRunnable * myRunnableObject
Definition: vlThread.h:48
Declares the DtRunnable class for defining a object that can be run in a thread.
Definition: vlRunnable.h:28
DtMutex myMutex
Shared lock for protecting critical sections.
Definition: vlThread.h:125
Abstract Threading Class Provides a system independent thread object.
Definition: vlThread.h:58
The thread start object.
Definition: vlThread.h:35
void(* DtRunnableFunction)(void *, volatile bool *)
Define the DtRunnableFunction interface to run a C function in a thread.
Definition: vlThread.h:29
This file contains typedefs for machine dependant types.
#define DT_DLL_VLUTIL
Definition: vlMachineTypes.h:109
bool myRunning
Active status Flag.
Definition: vlThread.h:119

Document ID: Generated on Tue Feb 2 21:02:17 EST 2021 from SVN revision 223668
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)