VR-Link API Documentation for HLA 1516
vlThreadedObject.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 1992-2010 VT MAK
3 ** All rights reserved.
4 ******************************************************************************/
9 #pragma once
10 
11 #include "vlSmartPointers.h"
12 #include "vlThread.h"
13 #include "vlRunnable.h"
14 #include "vlExceptions.h"
15 #include "vlMachineTypes.h"
16 
17 #ifdef DtUSE_UTILITIES_NAMESPACE
18 namespace DtUSE_UTILITIES_NAMESPACE
19 {
20 #endif
21 
22 
23 
24 typedef DtBoost::shared_ptr<DtRunnable> DtRunnableSP;
25 
27 #define typedefException(Name,Value) \
28  const int Name##Number = Value;\
29  typedef DtTemplatedException<Name##Number> Name;
30 const int ThreadExceptionBase = 1000;
31 typedefException(DtThreadAlreadyRunning,ThreadExceptionBase + 1)
32 typedefException(DtThreadNotStarted, ThreadExceptionBase + 2)
33 typedefException(DtThreadCreationError, ThreadExceptionBase + 3)
34 typedefException(DtThreadWouldDeadlock, ThreadExceptionBase + 4)
35 
36 
38 {
39 public:
42  DtThreadedObject();
43 
46  DtThreadedObject(DtRunnableSP ptr);
47 
49  virtual ~DtThreadedObject();
50 
56  void start();
57 
60  void join();
61 
65  void stop(bool block);
66 
68  bool running() const;
69 
72  void setRunnableObject(DtRunnableSP newObject);
73 
75  DtRunnableSP runnableObject() const;
76 
77 protected:
78 
80  DtThreadedObject(const DtThreadedObject&);
81  DtThreadedObject& operator=(const DtThreadedObject&);
82 
84  void setRunning(bool value);
85 
89  mutable DtMutex myMutex;
90 };
91 
92 
93 
94 #ifdef DtUSE_UTILITIES_NAMESPACE
95 }
96 #endif
97 
98 

Document ID: Generated on Wed Oct 23 22:25:48 EDT 2013 from SVN revision 132765
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)