Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

acsThreadManager.h

Go to the documentation of this file.
00001 #ifndef _ACS_THREAD_MANAGER_H 00002 #define _ACS_THREAD_MANAGER_H 00003 /******************************************************************************* 00004 * E.S.O. - VLT project 00005 * 00006 * "@(#) $Id: acsThreadManager.h,v 1.19 2008/10/13 23:15:12 bjeram Exp $" 00007 * 00008 * who when what 00009 * -------- ---------- ---------------------------------------------- 00010 * bjeram yyyy-mm-dd created 00011 */ 00012 00013 /************************************************************************ 00014 * 00015 *---------------------------------------------------------------------- 00016 */ 00017 00018 #ifndef __cplusplus 00019 #error This is a C++ include file and cannot be used from plain C 00020 #endif 00021 00022 #include "acsThread.h" 00023 #include "loggingLoggable.h" 00024 #include <ACSErrTypeCommon.h> 00025 00026 namespace ACS 00027 { 00028 00033 class ThreadManager : public ACS::ThreadManagerBase, 00034 public Logging::Loggable 00035 { 00036 friend class Thread; 00037 00038 public: 00039 00043 ThreadManager() : 00044 ACS::ThreadManagerBase(), 00045 Logging::Loggable() {} 00046 00052 ThreadManager(Logging::Logger::LoggerSmartPtr logger) : 00053 ACS::ThreadManagerBase(), 00054 Logging::Loggable(logger) {} 00055 00064 template <class T> 00065 T* create(const ACE_CString name); 00066 00067 /* 00068 * @throw acsthreadErrType::ThreadAlreadyExistExImpl 00069 * @throw acsthreadErrType::CanNotCreateThreadExImpl 00070 */ 00071 template <class T> 00072 T* create(const ACE_CString name, 00073 const TimeInterval responseTime, 00074 const TimeInterval sleepTime); 00075 /* 00076 * @throw acsthreadErrType::ThreadAlreadyExistExImpl 00077 * @throw acsthreadErrType::CanNotCreateThreadExImpl 00078 */ 00079 template <class T> 00080 T* create(const ACE_CString name, 00081 const TimeInterval responseTime, 00082 const TimeInterval sleepTime, 00083 bool del); 00084 00085 /* 00086 * @throw acsthreadErrType::ThreadAlreadyExistExImpl 00087 * @throw acsthreadErrType::CanNotCreateThreadExImpl 00088 */ 00089 template <class T> 00090 T* create(const ACE_CString name, 00091 const TimeInterval responseTime, 00092 const TimeInterval sleepTime, 00093 bool del, 00094 const long thrFlags); 00095 00096 /* 00097 * @throw acsthreadErrType::ThreadAlreadyExistExImpl 00098 * @throw acsthreadErrType::CanNotCreateThreadExImpl 00099 */ 00100 template <class T> 00101 T* create(const ACE_CString name, 00102 const TimeInterval responseTime, 00103 const TimeInterval sleepTime, 00104 bool del, 00105 const long thrFlags, 00106 const size_t stackSize); 00107 00116 template <class T, class P> 00117 T* create(const ACE_CString name, P&); 00118 00119 /* 00120 * @throw acsthreadErrType::ThreadAlreadyExistExImpl 00121 * @throw acsthreadErrType::CanNotCreateThreadExImpl 00122 */ 00123 template <class T, class P> 00124 T* create(const ACE_CString name, P&, 00125 const TimeInterval responseTime, 00126 const TimeInterval sleepTime); 00127 /* 00128 * @throw acsthreadErrType::ThreadAlreadyExistExImpl 00129 * @throw acsthreadErrType::CanNotCreateThreadExImpl 00130 */ 00131 template <class T, class P> 00132 T* create(const ACE_CString name, P&, 00133 const TimeInterval responseTime, 00134 const TimeInterval sleepTime, 00135 bool del); 00136 00137 /* 00138 * @throw acsthreadErrType::ThreadAlreadyExistExImpl 00139 * @throw acsthreadErrType::CanNotCreateThreadExImpl 00140 */ 00141 template <class T, class P> 00142 T* create(const ACE_CString name, P&, 00143 const TimeInterval responseTime, 00144 const TimeInterval sleepTime, 00145 bool del, 00146 const long thrFlags); 00147 00148 /* 00149 * @throw acsthreadErrType::ThreadAlreadyExistExImpl 00150 * @throw acsthreadErrType::CanNotCreateThreadExImpl 00151 */ 00152 template <class T, class P> 00153 T* create(const ACE_CString name, P&, 00154 const TimeInterval responseTime, 00155 const TimeInterval sleepTime, 00156 bool del, 00157 const long thrFlags, 00158 const size_t stackSize); 00159 00164 void destroy(ACS::Thread* thr) 00165 { 00166 if (thr!=NULL) 00167 { 00168 removeFromMap (thr->getName()); 00169 delete thr; 00170 thr = 0; 00171 }//if 00172 }//destroy 00173 00174 private: 00175 00179 void operator=(const ThreadManager&); 00180 00184 ThreadManager(const ThreadManager&); 00185 00193 class ThreadManagerTSS 00194 { 00195 public: 00196 ThreadManagerTSS() : m_tm(0){} 00197 00201 void setThreadManager(ThreadManager* _tm){ m_tm = _tm; } 00202 00207 ThreadManager* getThreadManager(bool _reset) 00208 { 00209 ThreadManager* tmp_tm = m_tm; 00210 if (_reset) 00211 m_tm = 0; 00212 return tmp_tm; 00213 } 00214 00218 void resetThreadManager() {m_tm = 0;} 00219 00220 protected: 00221 ThreadManager* m_tm; 00222 }; 00223 00227 static ACE_TSS<ThreadManagerTSS> threadManagerTSS; 00228 00229 };//class ThreadManager 00230 00231 /* implementation for template functions*/ 00232 #include "acsThreadManager.i" 00233 00234 };//namespace ACS 00235 00236 #endif

Generated on Thu Apr 30 02:30:49 2009 for ACS C++ API by doxygen 1.3.8