9 #ifndef ossimPool_HEADER 10 #define ossimPool_HEADER 20 #define OSSIM_DEFAULT_POOL_SIZE (ossim_uint32)10 48 <<
"FATAL ossimPool::ossimPool(): Bad allocation" << endl;
69 theCriticalSectionMutex.lock();
72 if (
thePool[idx]->theAvailableFlag ==
true)
74 thePool[idx]->theAvailableFlag =
false;
79 theCriticalSectionMutex.unlock();
92 void checkin(T* obj)
throw(std::out_of_range)
94 theCriticalSectionMutex.lock();
97 if (obj ==
thePool[idx]->theObjectPtr)
100 thePool[idx]->theAvailableFlag =
true;
101 theCriticalSectionMutex.unlock();
106 theCriticalSectionMutex.unlock();
107 throw std::out_of_range(
string(
"ossimPool<T>::checkin Error Object not managed by this pool!"));
117 out <<
"obj address: " << (hex) <<
thePool[idx]->theObjectPtr
119 << (
thePool[idx]->theAvailableFlag ?
"available":
"unavailable")
128 return obj.
print(out);
Container pool to be used for things like threads.
ossimPool(ossim_uint32 n=OSSIM_DEFAULT_POOL_SIZE)
Contructor.
#define OSSIM_DEFAULT_POOL_SIZE
std::vector< ossimPoolObject< T > * > thePool
os2<< "> n<< " > nendobj n
unsigned int ossim_uint32
Templated container for an object pointer and a flag.
std::ostream & print(std::ostream &out) const
Outputs object addresses and theAvailableFlag.
void checkin(T *obj)
Resets and eturns object to the pool.
friend std::ostream & operator<<(std::ostream &out, const ossimPool< C > &obj)
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
std::basic_ostream< char > ostream
Base class for char output streams.