00001
#if !defined(__CORELINUXGUARDPOOL_HPP)
00002
#define __CORELINUXGUARDPOOL_HPP
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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
00103
00104
00114
CoreLinuxGuardPool( Short numInit=8, Short numExt=0 )
00115
throw(
Assertion );
00116
00118
00119
virtual ~CoreLinuxGuardPool(
void );
00120
00121
00122
00123
00124
00125
00126
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
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
00188
00189
00198
bool isSynchronizedLocked(
SynchronizedPtr )
00199
throw(
SemaphoreException );
00200
00201
00202
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
00285
00286
00287
00288
00289
00290