#include <BlockWipedAllocator.h>
Classes | |
struct | Block |
struct | LocalCache |
struct | Stat |
Public Member Functions | |
void * | alloc () |
BlockWipedAllocator (std::size_t typeSize, std::size_t blockSize) | |
BlockWipedAllocator (BlockWipedAllocator const &rh) | |
void | clear () const |
void | dealloc (void *) |
BlockWipedAllocator & | operator= (BlockWipedAllocator const &rh) |
void | registerCache (LocalCache *c) |
Stat | stat () const |
void | wipe () const |
Protected Member Functions | |
BlockWipedAllocator & | me () const |
Private Types | |
typedef std::list< Block > | Blocks |
typedef Blocks::const_iterator | const_iterator |
typedef Blocks::iterator | iterator |
typedef unsigned char * | pointer |
Private Member Functions | |
void | nextBlock (bool advance) |
Private Attributes | |
std::vector< LocalCache * > | localCaches |
int | m_alive |
Blocks | m_blocks |
std::size_t | m_blockSize |
iterator | m_current |
pointer | m_next |
std::size_t | m_typeSize |
Definition at line 17 of file BlockWipedAllocator.h.
typedef std::list<Block> BlockWipedAllocator::Blocks [private] |
Definition at line 85 of file BlockWipedAllocator.h.
typedef Blocks::const_iterator BlockWipedAllocator::const_iterator [private] |
Definition at line 87 of file BlockWipedAllocator.h.
typedef Blocks::iterator BlockWipedAllocator::iterator [private] |
Definition at line 86 of file BlockWipedAllocator.h.
typedef unsigned char* BlockWipedAllocator::pointer [private] |
Definition at line 84 of file BlockWipedAllocator.h.
BlockWipedAllocator::BlockWipedAllocator | ( | std::size_t | typeSize, |
std::size_t | blockSize | ||
) |
Definition at line 4 of file BlockWipedAllocator.cc.
References wipe().
: m_typeSize(typeSize), m_blockSize(blockSize), m_alive(0){ if (typeSize<32) abort(); // throw std::bad_alloc(); wipe(); }
BlockWipedAllocator::BlockWipedAllocator | ( | BlockWipedAllocator const & | rh | ) |
Definition at line 12 of file BlockWipedAllocator.cc.
References wipe().
: m_typeSize(rh.m_typeSize), m_blockSize(rh.m_blockSize),m_alive(0) { wipe(); }
void * BlockWipedAllocator::alloc | ( | ) |
Definition at line 26 of file BlockWipedAllocator.cc.
References Association::block, m_alive, BlockWipedAllocator::Block::m_allocated, m_current, BlockWipedAllocator::Block::m_data, m_next, m_typeSize, nextBlock(), and runTheMatrix::ret.
Referenced by BlockWipedPoolAllocated::operator new(), BlockWipedAllocated< T >::operator new(), and SizeBlockWipedAllocated< T >::operator new().
void BlockWipedAllocator::clear | ( | void | ) | const |
Definition at line 41 of file BlockWipedAllocator.cc.
References m_blocks, me(), and wipe().
Referenced by BlockWipedPool::clear().
void BlockWipedAllocator::dealloc | ( | void * | ) |
Definition at line 37 of file BlockWipedAllocator.cc.
References m_alive.
Referenced by BlockWipedPoolAllocated::operator delete(), BlockWipedAllocated< T >::operator delete(), and SizeBlockWipedAllocated< T >::operator delete().
{ m_alive--; }
BlockWipedAllocator & BlockWipedAllocator::me | ( | ) | const [protected] |
Definition at line 54 of file BlockWipedAllocator.cc.
Referenced by clear(), and wipe().
{ return const_cast<BlockWipedAllocator&>(*this); }
void BlockWipedAllocator::nextBlock | ( | bool | advance | ) | [private] |
Definition at line 66 of file BlockWipedAllocator.cc.
References m_blocks, m_blockSize, m_current, m_next, and m_typeSize.
BlockWipedAllocator & BlockWipedAllocator::operator= | ( | BlockWipedAllocator const & | rh | ) |
Definition at line 17 of file BlockWipedAllocator.cc.
References m_alive, m_blockSize, m_typeSize, and wipe().
{ m_typeSize=rh.m_typeSize; m_blockSize=rh.m_blockSize; m_alive=0; wipe(); return *this; }
void BlockWipedAllocator::registerCache | ( | LocalCache * | c | ) | [inline] |
Definition at line 49 of file BlockWipedAllocator.h.
References localCaches.
{ localCaches.push_back(c); }
BlockWipedAllocator::Stat BlockWipedAllocator::stat | ( | ) | const |
Definition at line 58 of file BlockWipedAllocator.cc.
References m_alive, m_blocks, m_blockSize, m_current, m_next, m_typeSize, and asciidump::s.
Referenced by BlockWipedPoolAllocated::stat(), SizeBlockWipedAllocated< T >::stat(), and BlockWipedAllocated< T >::stat().
{ Stat s = { m_typeSize, m_blockSize, (*m_current).m_allocated, (&*(*m_current).m_data.end()-m_next)/m_typeSize, std::distance(const_iterator(m_current),m_blocks.end()), m_blocks.size(), m_alive}; return s; }
void BlockWipedAllocator::wipe | ( | ) | const |
Definition at line 46 of file BlockWipedAllocator.cc.
References localCaches, m_blocks, m_current, me(), nextBlock(), and BlockWipedAllocator::LocalCache::reset().
Referenced by BlockWipedAllocator(), clear(), operator=(), and BlockWipedPool::wipe().
{ // reset caches std::for_each(localCaches.begin(),localCaches.end(),boost::bind(&LocalCache::reset,_1)); me().m_current=me().m_blocks.begin(); me().nextBlock(false); }
std::vector<LocalCache*> BlockWipedAllocator::localCaches [private] |
Definition at line 54 of file BlockWipedAllocator.h.
Referenced by registerCache(), and wipe().
int BlockWipedAllocator::m_alive [private] |
Definition at line 96 of file BlockWipedAllocator.h.
Referenced by alloc(), dealloc(), operator=(), and stat().
Blocks BlockWipedAllocator::m_blocks [private] |
Definition at line 94 of file BlockWipedAllocator.h.
Referenced by clear(), nextBlock(), stat(), and wipe().
std::size_t BlockWipedAllocator::m_blockSize [private] |
Definition at line 91 of file BlockWipedAllocator.h.
Referenced by nextBlock(), operator=(), and stat().
iterator BlockWipedAllocator::m_current [private] |
Definition at line 93 of file BlockWipedAllocator.h.
Referenced by alloc(), nextBlock(), stat(), and wipe().
pointer BlockWipedAllocator::m_next [private] |
Definition at line 92 of file BlockWipedAllocator.h.
Referenced by alloc(), nextBlock(), and stat().
std::size_t BlockWipedAllocator::m_typeSize [private] |
Definition at line 90 of file BlockWipedAllocator.h.
Referenced by alloc(), nextBlock(), operator=(), and stat().