PixelLightAPI  .
TimerThread.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: TimerThread.h                                  *
00003  *
00004  *  Copyright (C) 2002-2011 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 __PLGUI_TIMERTHREAD_H__
00024 #define __PLGUI_TIMERTHREAD_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <PLCore/System/Thread.h>
00032 #include "PLGui/PLGui.h"
00033 
00034 
00035 //[-------------------------------------------------------]
00036 //[ Forward declarations                                  ]
00037 //[-------------------------------------------------------]
00038 namespace PLCore {
00039     class CriticalSection;
00040 }
00041 namespace PLGui {
00042     class Timer;
00043 }
00044 
00045 
00046 //[-------------------------------------------------------]
00047 //[ Namespace                                             ]
00048 //[-------------------------------------------------------]
00049 namespace PLGui {
00050 
00051 
00052 //[-------------------------------------------------------]
00053 //[ Classes                                               ]
00054 //[-------------------------------------------------------]
00055 /**
00056 *  @brief
00057 *    Timer operation thread
00058 */
00059 class TimerThread : public PLCore::Thread {
00060 
00061 
00062     //[-------------------------------------------------------]
00063     //[ Public functions                                      ]
00064     //[-------------------------------------------------------]
00065     public:
00066         /**
00067         *  @brief
00068         *    Constructor
00069         *
00070         *  @param[in] cTimer
00071         *    Reference to the owning Timer object
00072         *  @param[in] nTimeout
00073         *    Timeout (in milliseconds)
00074         *  @param[in] bOnce
00075         *    'true' if the timer shall fire only once, else 'false'
00076         */
00077         PLGUI_API TimerThread(Timer &cTimer, PLCore::uint64 nTimeout, bool bOnce);
00078 
00079         /**
00080         *  @brief
00081         *    Destructor
00082         */
00083         PLGUI_API virtual ~TimerThread();
00084 
00085         /**
00086         *  @brief
00087         *    Stop timer thread
00088         */
00089         PLGUI_API void StopTimer();
00090 
00091         /**
00092         *  @brief
00093         *    Fire timer
00094         */
00095         PLGUI_API void Fire();
00096 
00097 
00098     //[-------------------------------------------------------]
00099     //[ Private virtual PLCore::ThreadFunction functions      ]
00100     //[-------------------------------------------------------]
00101     private:
00102         virtual int Run() override;
00103 
00104 
00105     //[-------------------------------------------------------]
00106     //[ Private data                                          ]
00107     //[-------------------------------------------------------]
00108     private:
00109         Timer                    &m_cTimer;             /**< Timer to that this thread belongs */
00110         PLCore::CriticalSection *m_pCriticalSection;    /**< Timer critical section (always valid!) */
00111         PLCore::uint64           m_nTimeout;            /**< Timeout value */
00112         bool                     m_bOnce;               /**< Timer is firing only once? */
00113         volatile bool            m_bShutdown;           /**< Shutdown thread? */
00114 
00115 
00116 };
00117 
00118 
00119 //[-------------------------------------------------------]
00120 //[ Namespace                                             ]
00121 //[-------------------------------------------------------]
00122 } // PLGui
00123 
00124 
00125 #endif // __PLGUI_TIMERTHREAD_H__


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:51:04
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported