00001 /* 00002 * wsemaphore.h - Windows utility functions. 00003 * 00004 * This file is part of WindowsUtils. 00005 * 00006 * Copyright (C) 2003, Leiden University. 00007 * WindowsUtils is free software, see below. 00008 * 00009 * $Revision: $ 00010 * $Date: $ 00011 * $Source: $ 00012 * %Author: Martin J. Moene % 00013 * 00014 * Compiler : Borland-C++ 5.5.1 00015 * Operating system: 32-bit Windows 00016 * Hardware system : PC 00017 * 00018 * WindowsUtils is free software; you can redistribute it and/or modify 00019 * it under the terms of the GNU General Public License as published by 00020 * the Free Software Foundation; either version 2 of the License, or 00021 * (at your option) any later version. 00022 * 00023 * WindowsUtils is distributed in the hope that it will be useful, 00024 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00025 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00026 * GNU General Public License for more details. 00027 * 00028 * You should have received a copy of the GNU General Public License 00029 * along with mngdriver; if not, write to the Free Software 00030 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00031 */ 00032 00052 #ifndef __WSEMAPHORE_H 00053 #define __WSEMAPHORE_H 00054 00055 /* 00056 * Windows utilities. 00057 */ 00058 00059 namespace WindowsUtils { 00060 00068 //----------------------------------------------------------------------------- 00069 00077 class Semaphore 00078 { 00079 public: 00120 Semaphore ( const char * const inName = 0 00121 , const unsigned long inInitialCount = 0 00122 , const unsigned long inMaximumCount = 0 00123 ); 00124 00133 ~Semaphore (); 00134 00143 Semaphore & post (const unsigned long inPostCount = 1); 00144 00153 Semaphore & wait (const unsigned long inTimeout = 0); 00154 00159 unsigned long maxCount() const { return theMaxCount; } 00160 00161 protected: 00162 00163 private: 00164 00166 00170 Semaphore (const Semaphore & ); 00171 Semaphore & operator = (const Semaphore &); 00173 00174 unsigned theSemaphoreHandle; 00175 unsigned long theMaxCount; 00176 00177 }; // end Semaphore class declaration 00178 00181 } // namespace WindowsUtils 00182 00183 #endif // __WSEMAPHORE_H 00184 00185 /* 00186 * end of file 00187 */ 00188 00189