00001 #if !defined(__GATEWAYSEMAPHORE_HPP) 00002 #define __GATEWAYSEMAPHORE_HPP 00003 00004 /* 00005 CoreLinux++ 00006 Copyright (C) 1999,2000 CoreLinux Consortium 00007 00008 The CoreLinux++ Library is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU Library General Public License as 00010 published by the Free Software Foundation; either version 2 of the 00011 License, or (at your option) any later version. 00012 00013 The CoreLinux++ Library Library is distributed in the hope that it will 00014 be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 Library General Public License for more details. 00017 00018 You should have received a copy of the GNU Library General Public 00019 License along with the GNU C Library; see the file COPYING.LIB. If not, 00020 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00021 Boston, MA 02111-1307, USA. 00022 */ 00023 00024 #if !defined(__COMMON_HPP) 00025 #include <Common.hpp> 00026 #endif 00027 00028 #if !defined(__SEMAPHORE_HPP) 00029 #include <Semaphore.hpp> 00030 #endif 00031 00032 #if !defined(__MAP_HPP) 00033 #include <Map.hpp> 00034 #endif 00035 00036 namespace corelinux 00037 { 00038 DECLARE_CLASS( GatewaySemaphore ); 00039 00040 CORELINUX_MAP 00041 ( 00042 ThreadIdentifier, 00043 Count , 00044 std::less<ThreadIdentifier>, 00045 GatewayClient 00046 ); 00047 00072 class GatewaySemaphore : public Semaphore 00073 { 00074 public: 00075 00076 // 00077 // Constructors and destructors 00078 // 00079 00093 GatewaySemaphore 00094 ( 00095 SemaphoreGroupPtr, 00096 SemaphoreIdentifierRef, 00097 Count , 00098 bool Recursive = false, 00099 bool Balking = false 00100 ) throw ( NullPointerException ); 00101 00103 00104 virtual ~GatewaySemaphore( void ); 00105 00106 // 00107 // Accessors 00108 // 00109 00111 00112 virtual bool isLocked( void ); 00113 00115 00116 virtual bool isAnOwner( void ); 00117 00124 virtual Counter getOwnerRecursionQueueLength( void ); 00125 00126 00127 // 00128 // Mutators 00129 // 00130 00132 00133 virtual SemaphoreOperationStatus lockWithWait(void) 00134 throw( SemaphoreException ); 00135 00137 00138 virtual SemaphoreOperationStatus lockWithNoWait(void) 00139 throw( SemaphoreException ); 00140 00141 00143 00144 // virtual SemaphoreOperationStatus lockWithTimeOut( Timer ) 00145 // throw(SemaphoreException) = 0; 00146 00148 00149 virtual SemaphoreOperationStatus release(void) 00150 throw( SemaphoreException ); 00151 00152 protected: 00153 00154 // 00155 // Constructors 00156 // 00158 00159 GatewaySemaphore( void ) throw( Assertion ); 00160 00162 00163 GatewaySemaphore( GatewaySemaphoreCref ) 00164 throw( Assertion ); 00165 00166 // 00167 // Operator overloads 00168 // 00170 00171 GatewaySemaphoreRef operator=( GatewaySemaphoreCref ) 00172 throw( Assertion ); 00173 00174 // 00175 // Mutators 00176 // 00177 00178 SemaphoreOperationStatus lockAndAdd 00179 ( 00180 ThreadIdentifierRef aTid, 00181 Int aFlag = 0 00182 ); 00183 00184 00185 private: 00186 00188 00189 Count theMaxCount; 00190 00192 00193 GatewayClient theClients; 00194 00195 }; 00196 } 00197 00198 #endif // if !defined(__GATEWAYSEMAPHORE_HPP) 00199 /* 00200 Common rcs information do not modify 00201 $Author: prudhomm $ 00202 $Revision: 1.4 $ 00203 $Date: 2000/08/31 22:52:20 $ 00204 $Locker: $ 00205 */ 00206