PixelLightAPI  .
ThreadLinux.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: ThreadLinux.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_LINUX_H__
00024 #define __PLCORE_THREAD_LINUX_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <pthread.h>
00032 #include "PLCore/System/ThreadImpl.h"
00033 
00034 
00035 //[-------------------------------------------------------]
00036 //[ Namespace                                             ]
00037 //[-------------------------------------------------------]
00038 namespace PLCore {
00039 
00040 
00041 //[-------------------------------------------------------]
00042 //[ Forward declarations                                  ]
00043 //[-------------------------------------------------------]
00044 class Mutex;
00045 
00046 
00047 //[-------------------------------------------------------]
00048 //[ Classes                                               ]
00049 //[-------------------------------------------------------]
00050 /**
00051 *  @brief
00052 *    Linux 'Thread' implementation
00053 */
00054 class ThreadLinux : public ThreadImpl {
00055 
00056 
00057     //[-------------------------------------------------------]
00058     //[ Friends                                               ]
00059     //[-------------------------------------------------------]
00060     friend class Thread;
00061 
00062 
00063     //[-------------------------------------------------------]
00064     //[ Private functions                                     ]
00065     //[-------------------------------------------------------]
00066     private:
00067         /**
00068         *  @brief
00069         *    Constructor
00070         *
00071         *  @param[in] cThread
00072         *    Reference to the owning thread
00073         *  @param[in] bThreadID
00074         *    If true, use the given thread ID
00075         *  @param[in] nThreadID
00076         *    System specific thread ID
00077         *
00078         *  @remarks
00079         *    If 'bThreadID == true' and 'nThreadID == NULL_HANDLE', the current thread
00080         *    ID will be used. If called from the main thread, this is the
00081         *    main thread ID.
00082         */
00083         ThreadLinux(Thread &cThread, bool bThreadID, handle nThreadID);
00084 
00085         /**
00086         *  @brief
00087         *    Destructor
00088         */
00089         virtual ~ThreadLinux();
00090 
00091 
00092     //[-------------------------------------------------------]
00093     //[ Private virtual ThreadImpl functions                  ]
00094     //[-------------------------------------------------------]
00095     private:
00096         virtual handle GetID() const override;
00097         virtual bool IsActive() const override;
00098         virtual bool Start() override;
00099         virtual bool Terminate() override;
00100         virtual bool Join() override;
00101         virtual bool Join(uint64 nTimeout) override;
00102         virtual uint32 GetPriorityClass() const override;
00103         virtual bool SetPriorityClass(uint32 nPriorityClass) override;
00104         virtual uint32 GetPriority() const override;
00105         virtual bool SetPriority(uint32 nPriority) override;
00106 
00107 
00108     //[-------------------------------------------------------]
00109     //[ Private static functions                              ]
00110     //[-------------------------------------------------------]
00111     private:
00112         /**
00113         *  @brief
00114         *    Static thread callback function
00115         *
00116         *  @param[in] pParameter
00117         *    Parameter, can be a null pointer
00118         *
00119         *  @return
00120         *    Return value, can be a null pointer
00121         */
00122         static void *RunThread(void *pParameter);
00123 
00124 
00125     //[-------------------------------------------------------]
00126     //[ Private data                                          ]
00127     //[-------------------------------------------------------]
00128     private:
00129         pthread_t    m_nThreadID;       /**< PThread thread ID */
00130         Mutex       *m_pMutex;          /**< Mutex used to detect running state of the thread */
00131         uint32       m_nPriorityClass;  /**< Priority class the thread is in (type: Thread::EPriorityClass) */
00132         uint32       m_nPriority;       /**< Thread priority within the priority class it is in (type: Thread::EPriority) */
00133 
00134 
00135 };
00136 
00137 
00138 //[-------------------------------------------------------]
00139 //[ Namespace                                             ]
00140 //[-------------------------------------------------------]
00141 } // PLCore
00142 
00143 
00144 #endif // __PLCORE_THREAD_LINUX_H__


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:09:01
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported