36 #ifndef NEKTAR_LIB_UTILITES_THREAD_SPECIFIC_POOL_HPP
37 #define NEKTAR_LIB_UTILITES_THREAD_SPECIFIC_POOL_HPP
39 #include <boost/pool/pool.hpp>
45 #ifdef NEKTAR_USE_THREAD_SAFETY
46 #include <boost/thread/mutex.hpp>
102 #ifdef NEKTAR_USE_THREAD_SAFETY
103 boost::mutex::scoped_lock l(m_mutex);
105 void* result =
m_pool->malloc();
107 #if defined(NEKTAR_DEBUG) || defined(NEKTAR_FULLDEBUG)
120 #ifdef NEKTAR_USE_THREAD_SAFETY
121 boost::mutex::scoped_lock l(m_mutex);
123 #if defined(NEKTAR_DEBUG) || defined(NEKTAR_FULLDEBUG)
133 m_pool->free(
const_cast<void*
>(
p));
141 #ifdef NEKTAR_USE_THREAD_SAFETY
142 boost::mutex m_mutex;
150 typedef std::map<size_t, std::shared_ptr<detail::ThreadSpecificPool> >
PoolMapType;
163 typedef PoolMapType::value_type PairType;
196 return ::operator
new(bytes);
200 PoolMapType::iterator iter =
m_pools.lower_bound(bytes);
201 ASSERTL1(iter !=
m_pools.end(),
"The memory manager is mishandling a memory request for " +
202 std::to_string(bytes) +
" bytes of memory.");
204 return (*iter).second->Allocate();
220 ::operator
delete(
p);
224 PoolMapType::iterator iter =
m_pools.lower_bound(bytes);
225 ASSERTL1(iter !=
m_pools.end(),
"The memory manager is mishandling a memory request for " +
226 std::to_string(bytes) +
" bytes of memory.");
228 (*iter).second->Deallocate(
p);
234 std::map<size_t, std::shared_ptr<detail::ThreadSpecificPool> >
m_pools;
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
#define LIB_UTILITIES_EXPORT
void Deallocate(void *p, size_t bytes)
Deallocate memory claimed by an earlier call to allocate.
detail::ThreadSpecificPool m_fourBytePool
std::map< size_t, std::shared_ptr< detail::ThreadSpecificPool > > m_pools
std::map< size_t, std::shared_ptr< detail::ThreadSpecificPool > > PoolMapType
void * Allocate(size_t bytes)
Allocate a block of memory of size ByteSize.
ThreadSpecificPool(size_t ByteSize)
void Deallocate(const void *p)
Deallocate memory claimed by an earlier call to allocate.
void * Allocate()
Allocate a block of memory of size ByteSize.
MemPool & GetMemoryPool()