VR-Link API Documentation for DIS
vlThreadedObject.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 ** Copyright (c) 1992-2010 VT MAK
00003 ** All rights reserved.
00004 ******************************************************************************/
00009 #pragma once
00010 
00011 #include "vlSmartPointers.h"
00012 #include "vlThread.h"
00013 #include "vlRunnable.h"
00014 #include "vlExceptions.h"
00015 #include "vlMachineTypes.h"
00016 
00017 #ifdef DtUSE_UTILITIES_NAMESPACE
00018 namespace DtUSE_UTILITIES_NAMESPACE
00019 {
00020 #endif
00021 
00022 
00023 
00024 typedef DtBoost::shared_ptr<DtRunnable> DtRunnableSP;
00025 
00027 #define typedefException(Name,Value) \
00028    const int Name##Number = Value;\
00029    typedef DtTemplatedException<Name##Number> Name;
00030 const int ThreadExceptionBase = 1000;
00031 typedefException(DtThreadAlreadyRunning,ThreadExceptionBase + 1)
00032 typedefException(DtThreadNotStarted,    ThreadExceptionBase + 2)
00033 typedefException(DtThreadCreationError, ThreadExceptionBase + 3)
00034 typedefException(DtThreadWouldDeadlock, ThreadExceptionBase + 4)
00035 
00036 
00037 class DT_DLL_VLUTIL DtThreadedObject
00038 {
00039 public:
00042    DtThreadedObject(); 
00043 
00046    DtThreadedObject(DtRunnableSP ptr); 
00047 
00049    virtual ~DtThreadedObject();
00050 
00056    void start();
00057 
00060    void join(); 
00061 
00065    void stop(bool block);
00066 
00068    bool running() const;
00069 
00072    void setRunnableObject(DtRunnableSP newObject);
00073 
00075    DtRunnableSP runnableObject() const;   
00076 
00077 protected:
00078 
00080    DtThreadedObject(const DtThreadedObject&);
00081    DtThreadedObject& operator=(const DtThreadedObject&);
00082 
00084    void setRunning(bool value);
00085 
00086    bool                          myRunningFlag;
00087    DtRunnableSP                  myObject;
00088    DtThread*                     myThread;
00089    mutable DtMutex               myMutex;   
00090 };
00091 
00092 
00093 
00094 #ifdef DtUSE_UTILITIES_NAMESPACE
00095 } 
00096 #endif
00097 
00098 

Document ID: Generated on Mon May 14 08:06:18 EDT 2012 from SVN revision 114750
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)