CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Attributes
BlockWipedPool Class Reference

#include <BlockWipedAllocator.h>

Public Types

typedef BlockWipedAllocator Allocator
 
typedef __gnu_cxx::hash_map
< std::size_t, Allocator
Pool
 

Public Member Functions

Allocatorallocator (std::size_t typeSize)
 
 BlockWipedPool (std::size_t blockSize, std::size_t maxRecycle)
 
void clear ()
 
template<typename Visitor >
void visit (Visitor &visitor) const
 
void wipe (bool force=true)
 
 ~BlockWipedPool ()
 

Private Attributes

std::size_t m_blockSize
 
Allocatorm_last
 
std::size_t m_lastSize
 
std::size_t m_maxRecycle
 
Pool m_pool
 

Detailed Description

Definition at line 111 of file BlockWipedAllocator.h.

Member Typedef Documentation

Definition at line 113 of file BlockWipedAllocator.h.

typedef __gnu_cxx::hash_map<std::size_t, Allocator> BlockWipedPool::Pool

Definition at line 115 of file BlockWipedAllocator.h.

Constructor & Destructor Documentation

BlockWipedPool::BlockWipedPool ( std::size_t  blockSize,
std::size_t  maxRecycle 
)

Definition at line 95 of file BlockWipedAllocator.cc.

95  :
96  m_blockSize(blockSize), m_maxRecycle(maxRecycle), m_last(0), m_lastSize(0){}
std::size_t m_maxRecycle
std::size_t m_blockSize
std::size_t m_lastSize
BlockWipedPool::~BlockWipedPool ( )

Definition at line 98 of file BlockWipedAllocator.cc.

References clear().

98 {clear();}

Member Function Documentation

BlockWipedPool::Allocator & BlockWipedPool::allocator ( std::size_t  typeSize)

Definition at line 102 of file BlockWipedAllocator.cc.

References likely, m_blockSize, m_last, m_lastSize, m_maxRecycle, m_pool, AlCaHLTBitMon_ParallelJobs::p, and edm::second().

Referenced by BlockWipedPoolAllocated::allocator(), BlockWipedAllocated< _bqueue_item< T > >::allocator(), and blockWipedAllocator().

102  {
103  if likely(m_lastSize==typeSize) return *m_last;
104  Pool::iterator p=m_pool.find(typeSize);
105  m_lastSize=typeSize;
106  if likely (p!=m_pool.end()) return *(m_last = &(*p).second);
107  return *(m_last=&(*m_pool.insert(std::make_pair(typeSize,Allocator(typeSize, m_blockSize, m_maxRecycle))).first).second);
108 }
__gnu_cxx::hash_map< std::size_t, Allocator > Pool
std::size_t m_maxRecycle
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
U second(std::pair< T, U > const &p)
BlockWipedAllocator Allocator
std::size_t m_blockSize
#define end
Definition: vmac.h:38
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:49
bool first
Definition: L1TdeRCT.cc:94
std::size_t m_lastSize
#define likely(x)
Definition: Likely.h:20
if(dp >Float(M_PI)) dp-
void BlockWipedPool::clear ( void  )
template<typename Visitor >
void BlockWipedPool::visit ( Visitor &  visitor) const
inline
void BlockWipedPool::wipe ( bool  force = true)

Definition at line 110 of file BlockWipedAllocator.cc.

References m_pool, edm::second(), and BlockWipedAllocator::wipe().

Referenced by BlockWipedAllocatorService::preModule(), and BlockWipedAllocatorService::wiper().

110  {
111  std::for_each(m_pool.begin(),m_pool.end(),boost::bind(&Allocator::wipe,
112  boost::bind(&Pool::value_type::second,_1),force
113  ));
114 }
U second(std::pair< T, U > const &p)
void wipe(bool force=true) const

Member Data Documentation

std::size_t BlockWipedPool::m_blockSize
private

Definition at line 135 of file BlockWipedAllocator.h.

Referenced by allocator().

Allocator* BlockWipedPool::m_last
private

Definition at line 138 of file BlockWipedAllocator.h.

Referenced by allocator().

std::size_t BlockWipedPool::m_lastSize
private

Definition at line 139 of file BlockWipedAllocator.h.

Referenced by allocator().

std::size_t BlockWipedPool::m_maxRecycle
private

Definition at line 136 of file BlockWipedAllocator.h.

Referenced by allocator().

Pool BlockWipedPool::m_pool
private

Definition at line 137 of file BlockWipedAllocator.h.

Referenced by allocator(), clear(), visit(), and wipe().