PixelLightAPI  .
SemaphoreLinux.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: SemaphoreLinux.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_SEMAPHORE_LINUX_H__
00024 #define __PLCORE_SEMAPHORE_LINUX_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <semaphore.h>
00032 #include "PLCore/System/SemaphoreImpl.h"
00033 
00034 
00035 //[-------------------------------------------------------]
00036 //[ Namespace                                             ]
00037 //[-------------------------------------------------------]
00038 namespace PLCore {
00039 
00040 
00041 //[-------------------------------------------------------]
00042 //[ Classes                                               ]
00043 //[-------------------------------------------------------]
00044 /**
00045 *  @brief
00046 *    Linux 'Semaphore' implementation
00047 */
00048 class SemaphoreLinux : public SemaphoreImpl {
00049 
00050 
00051     //[-------------------------------------------------------]
00052     //[ Friends                                               ]
00053     //[-------------------------------------------------------]
00054     friend class Semaphore;
00055 
00056 
00057     //[-------------------------------------------------------]
00058     //[ Private functions                                     ]
00059     //[-------------------------------------------------------]
00060     private:
00061         /**
00062         *  @brief
00063         *    Constructor
00064         *
00065         *  @param[in] nValue
00066         *    Initial value of the semaphore
00067         *  @param[in] nMaxValue
00068         *    Maximum value of the semaphore
00069         */
00070         SemaphoreLinux(uint32 nValue, uint32 nMaxValue);
00071 
00072         /**
00073         *  @brief
00074         *    Destructor
00075         */
00076         virtual ~SemaphoreLinux();
00077 
00078 
00079     //[-------------------------------------------------------]
00080     //[ Private virtual SemaphoreImpl functions               ]
00081     //[-------------------------------------------------------]
00082     private:
00083         virtual bool Lock() override;
00084         virtual bool TryLock(uint64 nTimeout) override;
00085         virtual bool Unlock() override;
00086 
00087 
00088     //[-------------------------------------------------------]
00089     //[ Private data                                          ]
00090     //[-------------------------------------------------------]
00091     private:
00092         sem_t   m_hSemaphore;   /**< System semaphore handle */
00093         uint32  m_nMaxValue;    /**< Maximum value of the semaphore */
00094         bool    m_bCreated;     /**< Indicates if the semaphore was created */
00095 
00096 
00097 };
00098 
00099 
00100 //[-------------------------------------------------------]
00101 //[ Namespace                                             ]
00102 //[-------------------------------------------------------]
00103 } // PLCore
00104 
00105 
00106 #endif // __PLCORE_SEMAPHORE_LINUX_H__


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