18 #if !defined(XALAN_OBJECTCACHE_HEADER_GUARD)
19 #define XALAN_OBJECTCACHE_HEADER_GUARD
33 XALAN_CPP_NAMESPACE_BEGIN
37 template<
class ObjectType>
45 typedef ObjectType ThisType;
49 ThisType*
const theResult =
50 new (theGuard.
get()) ThisType();
60 template<
class ObjectType>
68 typedef ObjectType ThisType;
72 ThisType*
const theResult =
73 new (theGuard.
get()) ThisType(theManager);
83 template<
class ObjectType>
96 template<
class ObjectType>
104 theInstance->clear();
110 #if defined(XALAN_OBJECT_CACHE_KEEP_BUSY_LIST)
114 #if defined(XALAN_NO_DEFAULT_TEMPLATE_ARGUMENTS)
115 class CreateFunctorType,
116 class DeleteFunctorType,
117 class ResetFunctorType>
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);
147 #if !defined(XALAN_NO_STD_NAMESPACE)
152 m_availableList.
begin(),
153 m_availableList.
end(),
162 if (m_availableList.
empty() ==
true)
166 m_busyList.push_back(theNewObject);
172 ObjectType*
const theObject = m_availableList.
back();
174 m_busyList.push_back(theObject);
183 release(ObjectType* theInstance)
185 #if !defined(XALAN_NO_STD_NAMESPACE)
191 const IteratorType i =
197 if (i == m_busyList.end())
216 while (m_busyList.empty() ==
false)
218 ObjectType*
const theInstance = m_busyList.back();
224 m_busyList.pop_back();
258 #if defined(XALAN_NO_DEFAULT_TEMPLATE_ARGUMENTS)
259 class CreateFunctorType,
260 class DeleteFunctorType,
261 class ResetFunctorType>
277 XalanSize_t initialListSize = 0) :
279 m_availableList(theManager)
281 m_availableList.
reserve(initialListSize);
288 #if !defined(XALAN_NO_STD_NAMESPACE)
293 m_availableList.
begin(),
294 m_availableList.
end(),
303 if (m_availableList.
empty() ==
true)
309 ObjectType*
const theObject = m_availableList.
back();
358 template<
class XalanObjectCacheType>
367 m_cachedObject(theCache.
get())
373 if (m_cachedObject != 0)
375 m_cache.release(m_cachedObject);
382 return m_cachedObject;
402 XalanObjectCacheType& m_cache;
409 template<
class ObjectType>
413 DefaultCacheCreateFunctor<ObjectType>,
414 DeleteFunctor<ObjectType>,
415 DefaultCacheResetFunctor<ObjectType> >
427 MemoryManager& theManager,
428 XalanSize_t initialListSize = 0) :
436 template<
class ObjectType>
440 DefaultCacheCreateFunctorMemMgr<ObjectType>,
441 DeleteFunctor<ObjectType>,
442 DefaultCacheResetFunctor<ObjectType> >
454 MemoryManager& theManager,
455 XalanSize_t initialListSize = 0) :
463 XALAN_CPP_NAMESPACE_END