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