18#if !defined(XALAN_OBJECTCACHE_HEADER_GUARD)
19#define XALAN_OBJECTCACHE_HEADER_GUARD
37template<
class ObjectType>
45 typedef ObjectType ThisType;
60template<
class ObjectType>
68 typedef ObjectType ThisType;
83template<
class ObjectType>
96template<
class ObjectType>
110#if defined(XALAN_OBJECT_CACHE_KEEP_BUSY_LIST)
114#if defined(XALAN_NO_DEFAULT_TEMPLATE_ARGUMENTS)
115class CreateFunctorType,
116class DeleteFunctorType,
117class ResetFunctorType>
119class CreateFunctorType = DefaultCacheCreateFunctor<ObjectType>,
120class DeleteFunctorType = DeleteFunctor<ObjectType>,
121class ResetFunctorType = DefaultCacheResetFunctor<ObjectType> >
123class XalanObjectCache
127 typedef XalanVector<ObjectType*> VectorType;
129 typedef ObjectType CacheObjectType;
133 MemoryManager& theManager,
134 XalanSize_t initialListSize = 0) :
135 m_availableList(theManager),
136 m_busyList(theManager)
138 m_availableList.reserve(initialListSize);
140 m_busyList.reserve(initialListSize);
150 m_availableList.begin(),
151 m_availableList.end(),
152 m_deleteFunctor(theManager));
160 if (m_availableList.empty() ==
true)
162 ObjectType*
const theNewObject = m_createFunctor(m_availableList.getMemoryManager());
164 m_busyList.push_back(theNewObject);
170 ObjectType*
const theObject = m_availableList.back();
172 m_busyList.push_back(theObject);
174 m_availableList.pop_back();
181 release(ObjectType* theInstance)
185 typedef typename VectorType::iterator IteratorType;
187 const IteratorType i =
193 if (i == m_busyList.end())
199 m_resetFunctor(theInstance);
201 m_availableList.push_back(theInstance);
212 while (m_busyList.empty() ==
false)
214 ObjectType*
const theInstance = m_busyList.back();
216 m_resetFunctor(theInstance);
218 m_availableList.push_back(theInstance);
220 m_busyList.pop_back();
225 CreateFunctorType m_createFunctor;
227 DeleteFunctorType m_deleteFunctor;
229 ResetFunctorType m_resetFunctor;
234 XalanObjectCache(
const XalanObjectCache<ObjectType, CreateFunctorType, DeleteFunctorType, ResetFunctorType>& theRHS);
236 XalanObjectCache<ObjectType, CreateFunctorType, DeleteFunctorType, ResetFunctorType>&
237 operator=(
const XalanObjectCache<ObjectType, CreateFunctorType, DeleteFunctorType, ResetFunctorType>& theRHS);
241 VectorType m_availableList;
243 VectorType m_busyList;
254#if defined(XALAN_NO_DEFAULT_TEMPLATE_ARGUMENTS)
255class CreateFunctorType,
256class DeleteFunctorType,
257class ResetFunctorType>
259class CreateFunctorType = DefaultCacheCreateFunctor<ObjectType>,
260class DeleteFunctorType = DeleteFunctor<ObjectType>,
261class ResetFunctorType = DefaultCacheResetFunctor<ObjectType> >
287 m_availableList.begin(),
288 m_availableList.end(),
297 if (m_availableList.empty() ==
true)
299 return m_createFunctor(m_availableList.getMemoryManager());
303 ObjectType*
const theObject = m_availableList.back();
305 m_availableList.pop_back();
352template<
class XalanObjectCacheType>
367 if (m_cachedObject != 0)
369 m_cache.release(m_cachedObject);
376 return m_cachedObject;
398 CacheObjectType* m_cachedObject;
403template<
class ObjectType>
407 DefaultCacheCreateFunctor<ObjectType>,
408 DeleteFunctor<ObjectType>,
409 DefaultCacheResetFunctor<ObjectType> >
430template<
class ObjectType>
434 DefaultCacheCreateFunctorMemMgr<ObjectType>,
435 DeleteFunctor<ObjectType>,
436 DefaultCacheResetFunctor<ObjectType> >
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
void operator()(ObjectType *theInstance) const
ObjectType * operator()(MemoryManager &theManager) const
ObjectType * operator()(MemoryManager &theManager) const
void operator()(ObjectType *) const
GuardCachedObject(XalanObjectCacheType &theCache)
XalanObjectCacheType::CacheObjectType CacheObjectType
CacheObjectType * release()
CacheObjectType * get() const
MemMgrAutoPtrData release()
XalanMemoryManagerObjectCacheDefault(MemoryManager &theManager, XalanSize_t initialListSize=0)
XalanObjectCache< ObjectType, DefaultCacheCreateFunctorMemMgr< ObjectType >, DeleteFunctor< ObjectType >, DefaultCacheResetFunctor< ObjectType > > BaseClassType
XalanObjectCacheDefault(MemoryManager &theManager, XalanSize_t initialListSize=0)
XalanObjectCache< ObjectType, DefaultCacheCreateFunctor< ObjectType >, DeleteFunctor< ObjectType >, DefaultCacheResetFunctor< ObjectType > > BaseClassType
XalanVector< ObjectType * > VectorType
ObjectType CacheObjectType
XalanObjectCache(MemoryManager &theManager, XalanSize_t initialListSize=0)
bool release(ObjectType *theInstance)
CreateFunctorType m_createFunctor
ResetFunctorType m_resetFunctor
DeleteFunctorType m_deleteFunctor