Use the function-local thread_local memPool, but for gcc<9.1

This commit is contained in:
Laurent Rineau 2019-06-26 15:51:43 +02:00
parent 2ce7800239
commit 9eed06477d
1 changed files with 5 additions and 11 deletions

View File

@ -95,7 +95,11 @@ public:
#if defined(CGAL_HAS_THREADS) && defined(BOOST_GCC) && BOOST_GCC < 90100
if(memPool_ptr.get() == nullptr) {memPool_ptr.reset(new Self());}
Self& memPool = * memPool_ptr.get();
#endif
#elif defined(CGAL_HAS_THREADS) // use the C++11 implementation
static thread_local Self memPool;
#else // not CGAL_HAS_THREADS
static Self memPool;
#endif // not CGAL_HAS_THREADS
return memPool;
}
@ -105,10 +109,6 @@ private:
#if defined(CGAL_HAS_THREADS) && defined(BOOST_GCC) && BOOST_GCC < 90100
static boost::thread_specific_ptr<Self> memPool_ptr;
#elif defined(CGAL_HAS_THREADS) // use the C++11 implementation
static thread_local Self memPool;
#else // not CGAL_HAS_THREADS
static Self memPool;
#endif // not CGAL_HAS_THREADS
};
@ -116,12 +116,6 @@ private:
template <class T, int nObjects >
boost::thread_specific_ptr<MemoryPool<T, nObjects> >
MemoryPool<T, nObjects>::memPool_ptr;
#else // use C++11 or without CGAL_HAS_THREADS
template <class T, int nObjects >
# ifdef CGAL_HAS_THREADS
thread_local
# endif
MemoryPool<T, nObjects> MemoryPool<T, nObjects>::memPool;
#endif
template< class T, int nObjects >