CoreLinux++  0.4.32
CoreLinuxGuardPool.hpp
1 #if !defined(__CORELINUXGUARDPOOL_HPP)
2 #define __CORELINUXGUARDPOOL_HPP
3 
4 /*
5  CoreLinux++
6  Copyright (C) 1999,2000 CoreLinux Consortium
7 
8  The CoreLinux++ Library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Library General Public License as
10  published by the Free Software Foundation; either version 2 of the
11  License, or (at your option) any later version.
12 
13  The CoreLinux++ Library Library is distributed in the hope that it will
14  be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Library General Public License for more details.
17 
18  You should have received a copy of the GNU Library General Public
19  License along with the GNU C Library; see the file COPYING.LIB. If not,
20  write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  Boston, MA 02111-1307, USA.
22 */
23 
24 #if !defined(__COMMON_HPP)
25 #include <Common.hpp>
26 #endif
27 
28 #if !defined(__SINGLETON_HPP)
29 #include <Singleton.hpp>
30 #endif
31 
32 #if !defined(__SEMAPHOREGROUP_HPP)
33 #include <SemaphoreGroup.hpp>
34 #endif
35 
36 #if !defined(__VECTOR_HPP)
37 #include <Vector.hpp>
38 #endif
39 
40 #if !defined(__MAP_HPP)
41 #include <Map.hpp>
42 #endif
43 
44 
45 namespace corelinux
46 {
47 
48 
56  {
58 
60 
62 
64  };
65 
66  CORELINUX_VECTOR
67  (
69  GroupVector
70  );
71 
72  CORELINUX_MAP
73  (
76  std::less<AbstractSemaphorePtr>,
77  SemaphoreMap
78  );
79 
80  CORELINUX_MAP
81  (
84  std::less<SynchronizedPtr>,
85  MonitorMap
86  );
87 
88  DECLARE_CLASS( CoreLinuxGuardPool );
90 
98  {
99  public:
100 
101  //
102  // Constructors and destructor
103  //
104 
114  CoreLinuxGuardPool( Short numInit=8, Short numExt=0 )
115  throw( Assertion );
116 
118 
119  virtual ~CoreLinuxGuardPool( void );
120 
121  //
122  // Operator overloads
123  //
124 
125  //
126  // Accessors
127  //
128 
136  static bool isLocked( SynchronizedPtr ) throw( SemaphoreException );
137 
139 
140  static Short getInitialPoolSize( void );
141 
143 
144  static Short getExtentSize( void );
145 
147 
148  static Short getTotalCurrentSize( void );
149 
150  //
151  // Mutators
152  //
153 
162  static void lock( SynchronizedPtr ) throw( SemaphoreException );
163 
172  static void release( SynchronizedPtr ) throw( SemaphoreException );
173 
182  static void setExtentSize( Short aExtentSize ) throw( Assertion );
183 
184  protected:
185 
186  //
187  // Accessors
188  //
189 
199  throw( SemaphoreException );
200 
201  //
202  // Mutators
203  //
204 
213  throw( SemaphoreException );
214 
222  throw( SemaphoreException );
223 
234  void createPoolGroup( Short numSems, Short initSize=0 );
235 
245  void destroyPoolGroup( Index aGroup );
246 
247  protected:
248 
250 
252 
254 
255  static Short theInitialSize;
256 
258 
259  static Short theExtentSize;
260 
261  private:
262 
264 
265  GroupVector theGroups;
266 
268 
269  SemaphoreMap theSemaphores;
270 
272 
273  MonitorMap theCallers;
274 
276 
277  AbstractSemaphorePtr theControlSem;
278  };
279 }
280 
281 #endif // if !defined(__CORELINUXGUARDPOOL_HPP)
282 
283 /*
284  Common rcs information do not modify
285  $Author: prudhomm $
286  $Revision: 1.3 $
287  $Date: 2000/08/31 22:52:20 $
288  $Locker: $
289 */
290 
static Short getExtentSize(void)
Return the current grow by count for the pool.
Definition: CoreLinuxGuardPool.cpp:179
bool isSynchronizedLocked(SynchronizedPtr)
isSynchronizedLocked resolves whether Synchronized is in a locked state.
Definition: CoreLinuxGuardPool.cpp:232
static Short getTotalCurrentSize(void)
Return the current guard pool size.
Definition: CoreLinuxGuardPool.cpp:188
void releaseSynchronized(SynchronizedPtr)
releaseSynchronized manages the associations of objects to the semaphore in the pool when releasing a...
Definition: CoreLinuxGuardPool.cpp:331
Ensure a class only has one instance, and provide a global point of access to it. ...
Definition: Singleton.hpp:38
static Short getInitialPoolSize(void)
Return the initial guard count in the pool.
Definition: CoreLinuxGuardPool.cpp:170
static Short theInitialSize
Describes the inital pool size.
Definition: CoreLinuxGuardPool.hpp:255
Count theQueueLength
The number of Synchronized concurrent request.
Definition: CoreLinuxGuardPool.hpp:59
The CoreLinuxGuardPool is a private SemaphoreGroup resource for class objects that require synchroniz...
Definition: CoreLinuxGuardPool.hpp:97
A AbstractSemaphore supports the protocol that processes and/or threads agree to follow for the purpo...
Definition: AbstractSemaphore.hpp:85
void createPoolGroup(Short numSems, Short initSize=0)
createPoolGroup creates a semaphore set with the requested number of semaphores in the group and will...
Definition: CoreLinuxGuardPool.cpp:392
Index theGroupIndex
The SemaphoreGroup that this semaphore belongs to.
Definition: CoreLinuxGuardPool.hpp:63
static GuardPool theGuard
Singleton instance.
Definition: CoreLinuxGuardPool.hpp:251
static Short theExtentSize
Describes the size to add when going into extents.
Definition: CoreLinuxGuardPool.hpp:259
SemaphoreException is the base exception type for Semaphore.
Definition: SemaphoreException.hpp:39
virtual ~CoreLinuxGuardPool(void)
Virtual destructor.
Definition: CoreLinuxGuardPool.cpp:104
void lockSynchronized(SynchronizedPtr)
lockSynchronized manages the associations of objects to the semaphore in the pool in establishing the...
Definition: CoreLinuxGuardPool.cpp:245
Assertion is-a Exception created when an assertion fails.
Definition: Assertion.hpp:423
void destroyPoolGroup(Index aGroup)
destroyPoolGroup validates that all the semaphores in the extent are not being used and then destroys...
Definition: CoreLinuxGuardPool.cpp:417
Synchronized is a mixin which allows class objects to enable monitor functionality.
Definition: Synchronized.hpp:41
static void setExtentSize(Short aExtentSize)
Run time interface for changing the extent size.
static void release(SynchronizedPtr)
release is called by a guard object during its destruction.
Definition: CoreLinuxGuardPool.cpp:214
PoolDescriptor stores information about the ownership and usage of a semaphore in the pool...
Definition: CoreLinuxGuardPool.hpp:55
static bool isLocked(SynchronizedPtr)
isLocked determines if the object is currently locked.
Definition: CoreLinuxGuardPool.cpp:149
A SemaphoreGroup is an extension to the Linux semaphore set.
Definition: SemaphoreGroup.hpp:62
static void lock(SynchronizedPtr)
lock is called by a guard when control is needed over a objects resource access.
Definition: CoreLinuxGuardPool.cpp:197

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