PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: ThreadWindows.h * 00003 * 00004 * Copyright (C) 2002-2012 The PixelLight Team (http://www.pixellight.org/) 00005 * 00006 * This file is part of PixelLight. 00007 * 00008 * PixelLight is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License as published by 00010 * the Free Software Foundation, either version 3 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * PixelLight is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public License 00019 * along with PixelLight. If not, see <http://www.gnu.org/licenses/>. 00020 \*********************************************************/ 00021 00022 00023 #ifndef __PLCORE_THREAD_WINDOWS_H__ 00024 #define __PLCORE_THREAD_WINDOWS_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include "PLCore/PLCoreWindowsIncludes.h" 00032 #include "PLCore/System/ThreadImpl.h" 00033 00034 00035 //[-------------------------------------------------------] 00036 //[ Namespace ] 00037 //[-------------------------------------------------------] 00038 namespace PLCore { 00039 00040 00041 //[-------------------------------------------------------] 00042 //[ Classes ] 00043 //[-------------------------------------------------------] 00044 /** 00045 * @brief 00046 * Windows 'Thread' implementation 00047 */ 00048 class ThreadWindows : public ThreadImpl { 00049 00050 00051 //[-------------------------------------------------------] 00052 //[ Friends ] 00053 //[-------------------------------------------------------] 00054 friend class Thread; 00055 00056 00057 //[-------------------------------------------------------] 00058 //[ Private functions ] 00059 //[-------------------------------------------------------] 00060 private: 00061 /** 00062 * @brief 00063 * Constructor 00064 * 00065 * @param[in] cThread 00066 * Reference to the owning thread 00067 * @param[in] bThreadID 00068 * If true, use the given thread ID 00069 * @param[in] nThreadID 00070 * System specific thread ID 00071 * 00072 * @remarks 00073 * If 'bThreadID == true' and 'nThreadID == NULL_HANDLE', the current thread 00074 * ID will be used. If called from the main thread, this is the 00075 * main thread ID. 00076 */ 00077 ThreadWindows(Thread &cThread, bool bThreadID, handle nThreadID); 00078 00079 /** 00080 * @brief 00081 * Destructor 00082 */ 00083 virtual ~ThreadWindows(); 00084 00085 00086 //[-------------------------------------------------------] 00087 //[ Private virtual ThreadImpl functions ] 00088 //[-------------------------------------------------------] 00089 private: 00090 virtual handle GetID() const override; 00091 virtual bool IsActive() const override; 00092 virtual bool Start() override; 00093 virtual bool Terminate() override; 00094 virtual bool Join() override; 00095 virtual bool Join(uint64 nTimeout) override; 00096 virtual uint32 GetPriorityClass() const override; 00097 virtual bool SetPriorityClass(uint32 nPriorityClass) override; 00098 virtual uint32 GetPriority() const override; 00099 virtual bool SetPriority(uint32 nPriority) override; 00100 00101 00102 //[-------------------------------------------------------] 00103 //[ Private static functions ] 00104 //[-------------------------------------------------------] 00105 private: 00106 /** 00107 * @brief 00108 * Static thread callback function 00109 * 00110 * @param[in] lpParameter 00111 * Parameter, can be a null pointer 00112 * 00113 * @return 00114 * Return value 00115 */ 00116 static DWORD WINAPI ThreadProc(LPVOID lpParameter); 00117 00118 00119 //[-------------------------------------------------------] 00120 //[ Private data ] 00121 //[-------------------------------------------------------] 00122 private: 00123 HANDLE m_hThread; /**< Thread handle */ 00124 DWORD m_nThreadID; /**< Thread ID */ 00125 00126 00127 }; 00128 00129 00130 //[-------------------------------------------------------] 00131 //[ Namespace ] 00132 //[-------------------------------------------------------] 00133 } // PLCore 00134 00135 00136 #endif // __PLCORE_THREAD_WINDOWS_H__
|