38 #ifndef NEKATAR_LIB_UTILITES_THREAD_SPECIFIC_POOL_HPP
39 #define NEKATAR_LIB_UTILITES_THREAD_SPECIFIC_POOL_HPP
41 #include <boost/thread/tss.hpp>
42 #include <boost/pool/pool.hpp>
43 #include <boost/thread/mutex.hpp>
45 #include <loki/Singleton.h>
103 boost::mutex::scoped_lock l(
m_mutex);
104 void* result =
m_pool->malloc();
106 #if defined(NEKTAR_DEBUG) || defined(NEKTAR_FULLDEBUG)
108 #endif //defined(NEKTAR_DEBUG) || defined(NEKTAR_FULLDEBUG)
119 boost::mutex::scoped_lock l(
m_mutex);
120 #if defined(NEKTAR_DEBUG) || defined(NEKTAR_FULLDEBUG)
128 #endif //defined(NEKTAR_DEBUG) || defined(NEKTAR_FULLDEBUG)
130 m_pool->free(const_cast<void*>(p));
145 typedef std::map<size_t, boost::shared_ptr<detail::ThreadSpecificPool> >
PoolMapType;
158 typedef PoolMapType::value_type PairType;
191 return ::operator
new(bytes);
196 ASSERTL1(iter !=
m_pools.end(),
"The memory manager is mishandling a memory request for " +
197 boost::lexical_cast<std::string>(bytes) +
" bytes of memory.");
199 return (*iter).second->Allocate();
215 ::operator
delete(
p);
220 ASSERTL1(iter !=
m_pools.end(),
"The memory manager is mishandling a memory request for " +
221 boost::lexical_cast<std::string>(bytes) +
" bytes of memory.");
223 (*iter).second->Deallocate(p);
229 std::map<size_t, boost::shared_ptr<detail::ThreadSpecificPool> >
m_pools;
239 #endif //NEKATAR_LIB_UTILITES_THREAD_SPECIFIC_POOL_HPP
detail::ThreadSpecificPool m_fourBytePool
void Deallocate(void *p, size_t bytes)
Deallocate memory claimed by an earlier call to allocate.
void * Allocate(size_t bytes)
Allocate a block of memory of size ByteSize.
#define LIB_UTILITIES_EXPORT
std::map< size_t, boost::shared_ptr< detail::ThreadSpecificPool > > PoolMapType
MemPool & GetMemoryPool()
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
std::map< size_t, boost::shared_ptr< detail::ThreadSpecificPool > > m_pools
void Deallocate(const void *p)
Deallocate memory claimed by an earlier call to allocate.
static boost::mutex mutex
ThreadSpecificPool(size_t ByteSize)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
void * Allocate()
Allocate a block of memory of size ByteSize.