Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Examples

CoreLinuxGuardPool.hpp

00001 #if !defined(__CORELINUXGUARDPOOL_HPP) 00002 #define __CORELINUXGUARDPOOL_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(__SINGLETON_HPP) 00029 #include <Singleton.hpp> 00030 #endif 00031 00032 #if !defined(__SEMAPHOREGROUP_HPP) 00033 #include <SemaphoreGroup.hpp> 00034 #endif 00035 00036 #if !defined(__VECTOR_HPP) 00037 #include <Vector.hpp> 00038 #endif 00039 00040 #if !defined(__MAP_HPP) 00041 #include <Map.hpp> 00042 #endif 00043 00044 00045 namespace corelinux 00046 { 00047 00048 00055 struct PoolDescriptor 00056 { 00058 00059 Count theQueueLength; 00060 00062 00063 Index theGroupIndex; 00064 }; 00065 00066 CORELINUX_VECTOR 00067 ( 00068 SemaphoreGroupPtr, 00069 GroupVector 00070 ); 00071 00072 CORELINUX_MAP 00073 ( 00074 AbstractSemaphorePtr, 00075 PoolDescriptor, 00076 std::less<AbstractSemaphorePtr>, 00077 SemaphoreMap 00078 ); 00079 00080 CORELINUX_MAP 00081 ( 00082 SynchronizedPtr, 00083 AbstractSemaphorePtr, 00084 std::less<SynchronizedPtr>, 00085 MonitorMap 00086 ); 00087 00088 DECLARE_CLASS( CoreLinuxGuardPool ); 00089 DECLARE_TYPE( Singleton<CoreLinuxGuardPool>, GuardPool ); 00090 00097 class CoreLinuxGuardPool 00098 { 00099 public: 00100 00101 // 00102 // Constructors and destructor 00103 // 00104 00114 CoreLinuxGuardPool( Short numInit=8, Short numExt=0 ) 00115 throw( Assertion ); 00116 00118 00119 virtual ~CoreLinuxGuardPool( void ); 00120 00121 // 00122 // Operator overloads 00123 // 00124 00125 // 00126 // Accessors 00127 // 00128 00136 static bool isLocked( SynchronizedPtr ) throw( SemaphoreException ); 00137 00139 00140 static Short getInitialPoolSize( void ); 00141 00143 00144 static Short getExtentSize( void ); 00145 00147 00148 static Short getTotalCurrentSize( void ); 00149 00150 // 00151 // Mutators 00152 // 00153 00162 static void lock( SynchronizedPtr ) throw( SemaphoreException ); 00163 00172 static void release( SynchronizedPtr ) throw( SemaphoreException ); 00173 00182 static void setExtentSize( Short aExtentSize ) throw( Assertion ); 00183 00184 protected: 00185 00186 // 00187 // Accessors 00188 // 00189 00198 bool isSynchronizedLocked( SynchronizedPtr ) 00199 throw( SemaphoreException ); 00200 00201 // 00202 // Mutators 00203 // 00204 00212 void lockSynchronized( SynchronizedPtr ) 00213 throw( SemaphoreException ); 00214 00221 void releaseSynchronized( SynchronizedPtr ) 00222 throw( SemaphoreException ); 00223 00234 void createPoolGroup( Short numSems, Short initSize=0 ); 00235 00245 void destroyPoolGroup( Index aGroup ); 00246 00247 protected: 00248 00250 00251 static GuardPool theGuard; 00252 00254 00255 static Short theInitialSize; 00256 00258 00259 static Short theExtentSize; 00260 00261 private: 00262 00264 00265 GroupVector theGroups; 00266 00268 00269 SemaphoreMap theSemaphores; 00270 00272 00273 MonitorMap theCallers; 00274 00276 00277 AbstractSemaphorePtr theControlSem; 00278 }; 00279 } 00280 00281 #endif // if !defined(__CORELINUXGUARDPOOL_HPP) 00282 00283 /* 00284 Common rcs information do not modify 00285 $Author: prudhomm $ 00286 $Revision: 1.3 $ 00287 $Date: 2000/08/31 22:52:20 $ 00288 $Locker: $ 00289 */ 00290

This is the CoreLinux++ reference manual
Provided by The CoreLinux Consortium