00001 /* 00002 * Copyright (C) 2009, Edmundo Albuquerque de Souza e Silva. 00003 * 00004 * This file may be distributed under the terms of the Q Public License 00005 * as defined by Trolltech AS of Norway and appearing in the file 00006 * LICENSE.QPL included in the packaging of this file. 00007 * 00008 * THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING 00009 * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00010 * PURPOSE. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, 00011 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING 00012 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 00013 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 00014 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 00015 * 00016 * Thanks: Jose Renato Santos 00017 * 00018 */ 00019 00020 /////////////////////////////////////////////////////////////////// 00021 // RioSemaphore.h: interface for the CSemaphore class 00022 /////////////////////////////////////////////////////////////////// 00023 00024 #if !defined __RIOSEMAPHORE_H_ 00025 #define __RIOSEMAPHORE_H_ 00026 00027 #ifndef WINDOWS 00028 #include <semaphore.h> 00029 #include "RioUnix.h" 00030 #endif 00031 00032 class CSemaphore 00033 { 00034 private: 00035 #ifdef WINDOWS 00036 // WINDOWS32 implementation 00037 HANDLE m_handle; 00038 #else 00039 // UNIX implementation 00040 sem_t m_Semaphore; 00041 #endif 00042 bool m_isopen; 00043 00044 public: 00045 CSemaphore(int InitialValue, int MaxValue); 00046 virtual ~CSemaphore(); 00047 bool IsOpen(); 00048 void P(); 00049 void V(); 00050 }; 00051 00052 #endif // __RIOSEMAPHORE_H_