19 #if !defined(REUSABLEARENAALLOCATOR_INCLUDE_GUARD_1357924680)
20 #define REUSABLEARENAALLOCATOR_INCLUDE_GUARD_1357924680
37 template<
class ObjectType>
39 ReusableArenaBlock<ObjectType> >
66 MemoryManager& theManager,
68 bool destroyBlocks =
false) :
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())
115 this->m_blocks.erase(iTerator);
117 this->m_blocks.push_front(block);
138 while ( !bResult && rIterator != rEnd )
140 if ((*rIterator)->ownsBlock(theObject))
142 (*rIterator)->destroyObject(theObject);
144 if (rIterator != this->m_blocks.rbegin())
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() )
230 assert ( fullBlock != 0 );
232 this->m_blocks.pop_front();
234 this->m_blocks.push_back( fullBlock );
242 if ( this->m_blocks.empty() )
249 while( iTerator != iEnd
250 && (*iTerator)->blockAvailable() )
252 if ((*iTerator)->ownsBlock(theObject) )
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)
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)