19 #if !defined(REUSABLEARENAALLOCATOR_INCLUDE_GUARD_1357924680)
20 #define REUSABLEARENAALLOCATOR_INCLUDE_GUARD_1357924680
37 template<
class ObjectType>
39 ReusableArenaBlock<ObjectType> >
66 MemoryManager& theManager,
67 size_type theBlockSize,
68 bool destroyBlocks =
false) :
69 BaseClassType(theManager, theBlockSize),
70 m_destroyBlocks(destroyBlocks)
90 assert ( theObject != 0 );
92 if ( this->m_blocks.empty() )
95 iterator iTerator = this->m_blocks.begin();
97 iterator iEnd = this->m_blocks.end();
100 while( iTerator != iEnd
101 && (*iTerator)->blockAvailable() )
103 if ((*iTerator)->ownsBlock(theObject) ==
true)
105 (*iTerator)->destroyObject(theObject);
108 if (iTerator != this->m_blocks.begin())
111 ReusableArenaBlockType* block = *iTerator;
115 this->m_blocks.erase(iTerator);
117 this->m_blocks.push_front(block);
133 reverse_iterator rIterator = this->m_blocks.rbegin();
135 reverse_iterator rEnd = this->m_blocks.rend();
138 while ( !bResult && rIterator != rEnd )
140 if ((*rIterator)->ownsBlock(theObject))
142 (*rIterator)->destroyObject(theObject);
144 if (rIterator != this->m_blocks.rbegin())
147 ReusableArenaBlockType* block = *iTerator;
151 this->m_blocks.erase(iTerator);
153 this->m_blocks.push_front(block);
167 if ( *rIterator == *iTerator)
193 if( this->m_blocks.empty()
194 || !this->m_blocks.front()->blockAvailable() )
196 this->m_blocks.push_front(
197 ReusableArenaBlockType::create(
198 this->getMemoryManager(),
201 assert( this->m_blocks.front() != 0 );
204 assert( this->m_blocks.front() != 0 );
205 assert( this->m_blocks.front()->blockAvailable() );
207 return this->m_blocks.front()->allocateBlock();
220 assert( this->m_blocks.empty() == false );
221 assert( this->m_blocks.front() != 0 );
222 assert( this->m_blocks.front()->ownsBlock(theObject) == true );
224 this->m_blocks.front()->commitAllocation(theObject);
226 if( !this->m_blocks.front()->blockAvailable() )
228 ReusableArenaBlockType* fullBlock = this->m_blocks.front();
230 assert ( fullBlock != 0 );
232 this->m_blocks.pop_front();
234 this->m_blocks.push_back( fullBlock );
242 if ( this->m_blocks.empty() )
245 const_iterator iTerator = this->m_blocks.begin();
247 const_iterator iEnd = this->m_blocks.end();
249 while( iTerator != iEnd
250 && (*iTerator)->blockAvailable() )
252 if ((*iTerator)->ownsBlock(theObject) )
260 const_reverse_iterator rIterator = this->m_blocks.rbegin();
262 const_reverse_iterator rEnd = this->m_blocks.rend();
264 while( rIterator != rEnd )
266 if ((*rIterator)->ownsBlock(theObject) )
271 if ( *iTerator == *rIterator )
294 assert(m_destroyBlocks ==
true);
296 if ( this->m_blocks.empty() ==
false)
298 const_iterator iTerator = this->m_blocks.begin();
300 if ( (*iTerator)->isEmpty() )
304 if (iTerator == this->m_blocks.end() ||
305 (*iTerator)->blockAvailable() )
307 this->m_blocks.pop_front();
334 #endif // !defined(REUSABLEARENAALLOCATOR_INCLUDE_GUARD_1357924680)
Xalan implementation of a doubly linked list.
bool operator==(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
reverse_iterator_ reverse_iterator
ReusableArenaAllocator< ObjectType > ThisType
virtual ~ReusableArenaAllocator()
const_reverse_iterator_ const_reverse_iterator
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
ArenaBlockListType::reverse_iterator reverse_iterator
virtual bool ownsObject(const ObjectType *theObject) const
virtual ObjectType * allocateBlock()
ArenaBlockListType::const_reverse_iterator const_reverse_iterator
virtual void commitAllocation(ObjectType *theObject)
BaseClassType::size_type size_type
XalanList< ReusableArenaBlockType * > ArenaBlockListType
ReusableArenaBlock< ObjectType > ReusableArenaBlockType
const bool m_destroyBlocks
ArenaBlockListType::const_iterator const_iterator
ReusableArenaAllocator(MemoryManager &theManager, size_type theBlockSize, bool destroyBlocks=false)
ReusableArenaBlockType::size_type size_type
ArenaAllocator< ObjectType, ReusableArenaBlockType > BaseClassType
bool destroyObject(ObjectType *theObject)
ArenaBlockListType::iterator iterator