00001 /* 00002 * semaphor.h 00003 * 00004 * Thread synchronisation semaphore class. 00005 * 00006 * Portable Windows Library 00007 * 00008 * Copyright (c) 1993-1998 Equivalence Pty. Ltd. 00009 * 00010 * The contents of this file are subject to the Mozilla Public License 00011 * Version 1.0 (the "License"); you may not use this file except in 00012 * compliance with the License. You may obtain a copy of the License at 00013 * http://www.mozilla.org/MPL/ 00014 * 00015 * Software distributed under the License is distributed on an "AS IS" 00016 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00017 * the License for the specific language governing rights and limitations 00018 * under the License. 00019 * 00020 * The Original Code is Portable Windows Library. 00021 * 00022 * The Initial Developer of the Original Code is Equivalence Pty. Ltd. 00023 * 00024 * Portions are Copyright (C) 1993 Free Software Foundation, Inc. 00025 * All Rights Reserved. 00026 * 00027 * Contributor(s): ______________________________________. 00028 * 00029 * $Revision: 20385 $ 00030 * $Author: rjongbloed $ 00031 * $Date: 2008-06-04 10:40:38 +0000 (Wed, 04 Jun 2008) $ 00032 */ 00033 00034 #ifndef _PSEMAPHORE 00035 #define _PSEMAPHORE 00036 00037 #ifdef P_USE_PRAGMA 00038 #pragma interface 00039 #endif 00040 00041 #include <ptlib/psync.h> 00042 #include <limits.h> 00043 #include <ptlib/critsec.h> 00044 00078 class PSemaphore : public PSync 00079 { 00080 PCLASSINFO(PSemaphore, PSync); 00081 00082 public: 00089 PSemaphore( 00090 unsigned initial, 00091 unsigned maximum 00092 ); 00093 00096 PSemaphore(const PSemaphore &); 00097 00101 ~PSemaphore(); 00103 00109 virtual void Wait(); 00110 00117 virtual PBoolean Wait( 00118 const PTimeInterval & timeout // Amount of time to wait for semaphore. 00119 ); 00120 00125 virtual void Signal(); 00126 00133 virtual PBoolean WillBlock() const; 00135 00136 private: 00137 PSemaphore & operator=(const PSemaphore &) { return *this; } 00138 00139 00140 // Include platform dependent part of class 00141 #ifdef _WIN32 00142 #include "msos/ptlib/semaphor.h" 00143 #else 00144 #include "unix/ptlib/semaphor.h" 00145 #endif 00146 }; 00147 00148 #endif 00149 00150 // End Of File ///////////////////////////////////////////////////////////////