VR-Link API Documentation for HLA Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vlThreadedObject.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 1992-2010 MAK Technologies, Inc
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 
This file declares vlException.
DtBoost::shared_ptr< DtRunnable > DtRunnableSP
Definition: vlThreadedObject.h:24
bool myRunningFlag
Definition: vlThreadedObject.h:86
Includes Boost smart pointers and aliases the Boost namespace.
Definition: vlThreadedObject.h:37
Contains declaration of DtRunnable abstract class.
const int ThreadExceptionBase
Definition: vlThreadedObject.h:30
This file contains the declaration of DtThreadStart and DtThread classes.
DtRunnableSP myObject
Definition: vlThreadedObject.h:87
instances of DtMutex are used to provide a platform independent mutual exclusion mechanism ...
Definition: vlMutex.h:31
DtMutex myMutex
Definition: vlThreadedObject.h:89
DtThread * myThread
Definition: vlThreadedObject.h:88
Abstract Threading Class Provides a system independent thread object.
Definition: vlThread.h:58
This file contains typedefs for machine dependant types.
#define DT_DLL_VLUTIL
Definition: vlMachineTypes.h:109
#define typedefException(Name, Value)
Define a set of thread related exceptions.
Definition: vlThreadedObject.h:27

Document ID: Generated on Thu Sep 19 02:12:35 EDT 2024 from SVN revision 269601
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)