mirror of https://github.com/CGAL/cgal
WIP: In Lazy.h we now have a single macro for boost and c++11 thread
This commit is contained in:
parent
aa649eccc9
commit
a14cf913e9
|
|
@ -784,25 +784,11 @@ private:
|
|||
// which is in particular heavily used for pruning DAGs.
|
||||
static const Self & zero()
|
||||
{
|
||||
#ifdef CGAL_HAS_THREADS
|
||||
#if BOOST_MSVC
|
||||
CGAL_THREAD_LOCAL static Self* z = NULL;
|
||||
if(z == NULL){
|
||||
z = new Self(new Lazy_rep_0<AT, ET, E2A>());
|
||||
}
|
||||
return *z;
|
||||
#else
|
||||
static boost::thread_specific_ptr<Self> z;
|
||||
|
||||
if (z.get() == NULL) {
|
||||
z.reset(new Self(new Lazy_rep_0<AT, ET, E2A>()));
|
||||
}
|
||||
return * z.get();
|
||||
#endif
|
||||
#else
|
||||
static const Self z = new Lazy_rep_0<AT, ET, E2A>();
|
||||
Lazy_rep_0<AT, ET, E2A>* ptr = new Lazy_rep_0<AT, ET, E2A>();
|
||||
CGAL_THREAD_LOCAL_DECLARE(Self,z);
|
||||
CGAL_THREAD_LOCAL_INITIALIZE(Self,z, ptr);
|
||||
CGAL_THREAD_LOCAL_GET(Self,z);
|
||||
return z;
|
||||
#endif
|
||||
}
|
||||
|
||||
Self_rep * ptr() const { return (Self_rep*) PTR; }
|
||||
|
|
|
|||
|
|
@ -420,7 +420,7 @@ using std::max;
|
|||
|
||||
#if ( defined(__GNUC__) && defined(__GNUC_MINOR__) \
|
||||
&& (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 \
|
||||
&& __cplusplus >= 201103L ) || ( _MSC_VER > 1900 )
|
||||
&& __cplusplus >= 201103L ) || ( _MSC_VER >= 1900 )
|
||||
#define CGAL_CAN_USE_CXX11_THREAD_LOCAL
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -5,17 +5,65 @@
|
|||
|
||||
#if defined( CGAL_HAS_THREADS )
|
||||
#ifdef CGAL_CAN_USE_CXX11_THREAD_LOCAL
|
||||
#pragma message ( "Use keyword thread_local" )
|
||||
#include <thread>
|
||||
#define CGAL_THREAD_LOCAL thread_local
|
||||
#else
|
||||
#ifdef BOOST_MSVC
|
||||
#include <thread>
|
||||
#pragma message ("Use __declspec( thread )" )
|
||||
#define CGAL_THREAD_LOCAL __declspec( thread )
|
||||
#else
|
||||
#pragma message ("Use thread_local from boost")
|
||||
#define CGAL_USE_BOOST_THREAD
|
||||
#include <boost/thread/tss.hpp>
|
||||
#define CGAL_THREAD_LOCAL thread_local
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CGAL_USE_BOOST_THREAD
|
||||
|
||||
#define CGAL_THREAD_LOCAL_DECLARE(TYPE, VAR) static boost::thread_specific_ptr<TYPE> VAR##_ptr
|
||||
|
||||
#define CGAL_THREAD_LOCAL_DECLARE_PTR(TYPE, VAR) static boost::thread_specific_ptr<TYPE> VAR
|
||||
|
||||
#define CGAL_THREAD_LOCAL_IS_UNINITIALIZED(X) X.get() == NULL
|
||||
|
||||
#define CGAL_THREAD_LOCAL_INITIALIZE_PTR(VAR, VAL) if(VAR.get() == NULL) {VAR.reset(VAL);}
|
||||
|
||||
#define CGAL_THREAD_LOCAL_INITIALIZE(TYPE, VAR, VAL) if(VAR##_ptr.get() == NULL) {VAR##_ptr.reset(new TYPE(VAL));}
|
||||
|
||||
#define CGAL_THREAD_LOCAL_SET(VAR, VAL) VAR.reset(VAL)
|
||||
|
||||
#define CGAL_THREAD_LOCAL_GET_PTR(VAR) VAR.get()
|
||||
|
||||
#define CGAL_THREAD_LOCAL_GET(TYPE, VAR) const TYPE& VAR = * VAR##_ptr.get()
|
||||
|
||||
#else
|
||||
|
||||
#define CGAL_THREAD_LOCAL_DECLARE(TYPE, VAR) static CGAL_THREAD_LOCAL TYPE* VAR##_ptr = NULL
|
||||
|
||||
#define CGAL_THREAD_LOCAL_DECLARE_PTR(TYPE, VAR) static CGAL_THREAD_LOCAL TYPE* VAR = NULL
|
||||
|
||||
#define CGAL_THREAD_LOCAL_IS_UNINITIALIZED(X) X == NULL
|
||||
|
||||
#define CGAL_THREAD_LOCAL_INITIALIZE_PTR(VAR, VAL) if(VAR == NULL) { VAR = VAL; }
|
||||
|
||||
#define CGAL_THREAD_LOCAL_INITIALIZE(TYPE, VAR, VAL) if(VAR##_ptr == NULL) { VAR##_ptr = new TYPE(VAL); }
|
||||
|
||||
#define CGAL_THREAD_LOCAL_SET(VAR, VAL) VAR = VAL
|
||||
|
||||
#define CGAL_THREAD_LOCAL_GET_PTR(VAR) VAR
|
||||
|
||||
#define CGAL_THREAD_LOCAL_GET(TYPE, VAR) const TYPE& VAR = *VAR##_ptr
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#define CGAL_THREAD_LOCAL_INITIALIZE(TYPE, VAR, VAL) static const TYPE VAR = VAL;
|
||||
#define CGAL_THREAD_LOCAL_DECLARE(TYPE, VAR)
|
||||
#define CGAL_THREAD_LOCAL_GET(TYPE, VAR)
|
||||
|
||||
#endif
|
||||
|
||||
#endif // CGAL_TSS_H
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ private:
|
|||
CGAL_EXPORT static const double CST_CUT;
|
||||
|
||||
#ifdef CGAL_HAS_THREADS
|
||||
#ifdef BOOST_MSVC
|
||||
#ifndef CGAL_USE_BOOST_THREAD
|
||||
CGAL_EXPORT CGAL_THREAD_LOCAL static int prime_int;
|
||||
CGAL_EXPORT CGAL_THREAD_LOCAL static double prime;
|
||||
CGAL_EXPORT CGAL_THREAD_LOCAL static double prime_inv;
|
||||
|
|
@ -207,7 +207,7 @@ public:
|
|||
set_current_prime(int p){
|
||||
int old_prime = get_prime_int();
|
||||
#ifdef CGAL_HAS_THREADS
|
||||
#ifdef BOOST_MSVC
|
||||
#ifndef CGAL_USE_BOOST_THREAD
|
||||
prime_int = p;
|
||||
prime = double(p);
|
||||
prime_inv = 1.0 / prime;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
namespace CGAL{
|
||||
#ifdef CGAL_HAS_THREADS
|
||||
#ifdef BOOST_MSVC
|
||||
#ifndef CGAL_USE_BOOST_THREAD
|
||||
CGAL_THREAD_LOCAL int Residue::prime_int = 67111067;
|
||||
CGAL_THREAD_LOCAL double Residue::prime = 67111067.0;
|
||||
CGAL_THREAD_LOCAL double Residue::prime_inv = 1490067204.5640400859667452463541;
|
||||
|
|
|
|||
|
|
@ -1053,44 +1053,40 @@ remove_and_give_new_faces(Vertex_handle v, OutputItFaces fit)
|
|||
afi++) *fit++ = afi;
|
||||
}
|
||||
else {
|
||||
#ifdef CGAL_HAS_THREADS
|
||||
#ifdef BOOST_MSVC
|
||||
CGAL_THREAD_LOCAL static int maxd = 30;
|
||||
# ifdef CGAL_HAS_THREADS
|
||||
# ifdef CGAL_USE_BOOST_THREAD
|
||||
static boost::thread_specific_ptr< int > maxd_ptr;
|
||||
CGAL_THREAD_LOCAL_DECLARE_PTR(std::vector<Face_handle> >, f_ptr);
|
||||
CGAL_THREAD_LOCAL_DECLARE_PTR(std::vector<int> >, i_ptr);
|
||||
CGAL_THREAD_LOCAL_DECLARE_PTR(std::vector<Vertex_handle> >, w_ptr);
|
||||
if (CGAL_THREAD_LOCAL_IS_UNINITIALIZED(f_ptr)) {
|
||||
maxd_ptr.reset(new int(30));
|
||||
CGAL_THREAD_LOCAL_SET(f_ptr, new std::vector<Face_handle>(*maxd_ptr));
|
||||
CGAL_THREAD_LOCAL_SET(i_ptr, new std::vector<int>(*maxd_ptr));
|
||||
CGAL_THREAD_LOCAL_SET(w_ptr, new std::vector<Vertex_handle>(*maxd_ptr));
|
||||
}
|
||||
int& maxd=*maxd_ptr;
|
||||
# else
|
||||
CGAL_THREAD_LOCAL static int maxd = 30;
|
||||
|
||||
CGAL_THREAD_LOCAL static std::vector<Face_handle>* f_ptr;
|
||||
CGAL_THREAD_LOCAL static std::vector<int>* i_ptr;
|
||||
CGAL_THREAD_LOCAL static std::vector<Vertex_handle>* w_ptr;
|
||||
if (f_ptr == NULL) {
|
||||
f_ptr = new std::vector<Face_handle>(maxd);
|
||||
i_ptr = new std::vector<int>(maxd);
|
||||
w_ptr = new std::vector<Vertex_handle>(maxd);
|
||||
}
|
||||
std::vector<Face_handle>& f=*f_ptr;
|
||||
std::vector<int>& i=*i_ptr;
|
||||
std::vector<Vertex_handle>& w=*w_ptr;
|
||||
#else
|
||||
|
||||
static boost::thread_specific_ptr< int > maxd_ptr;
|
||||
static boost::thread_specific_ptr< std::vector<Face_handle> > f_ptr;
|
||||
static boost::thread_specific_ptr< std::vector<int> > i_ptr;
|
||||
static boost::thread_specific_ptr< std::vector<Vertex_handle> > w_ptr;
|
||||
if (maxd_ptr.get() == NULL) {
|
||||
maxd_ptr.reset(new int(30));
|
||||
f_ptr.reset(new std::vector<Face_handle>(*maxd_ptr));
|
||||
i_ptr.reset(new std::vector<int>(*maxd_ptr));
|
||||
w_ptr.reset(new std::vector<Vertex_handle>(*maxd_ptr));
|
||||
}
|
||||
int& maxd=*maxd_ptr;
|
||||
std::vector<Face_handle>& f=*f_ptr;
|
||||
std::vector<int>& i=*i_ptr;
|
||||
std::vector<Vertex_handle>& w=*w_ptr;
|
||||
#endif
|
||||
#else
|
||||
static int maxd=30;
|
||||
static std::vector<Face_handle> f(maxd);
|
||||
static std::vector<int> i(maxd);
|
||||
static std::vector<Vertex_handle> w(maxd);
|
||||
#endif
|
||||
CGAL_THREAD_LOCAL_DECLARE_PTR(std::vector<Face_handle> >, f_ptr);
|
||||
CGAL_THREAD_LOCAL_DECLARE_PTR(std::vector<int> >, i_ptr);
|
||||
CGAL_THREAD_LOCAL_DECLARE_PTR(std::vector<Vertex_handle> >, w_ptr);
|
||||
if (CGAL_THREAD_LOCAL_IS_UNINITIALIZED(f_ptr)) {
|
||||
CGAL_THREAD_LOCAL_SET(f_ptr, new std::vector<Face_handle>(*maxd_ptr));
|
||||
CGAL_THREAD_LOCAL_SET(i_ptr, new std::vector<int>(*maxd_ptr));
|
||||
CGAL_THREAD_LOCAL_SET(w_ptr, new std::vector<Vertex_handle>(*maxd_ptr));
|
||||
}
|
||||
# endif
|
||||
std::vector<Face_handle>& f=*f_ptr;
|
||||
std::vector<int>& i=*i_ptr;
|
||||
std::vector<Vertex_handle>& w=*w_ptr;
|
||||
# else
|
||||
static int maxd=30;
|
||||
static std::vector<Face_handle> f(maxd);
|
||||
static std::vector<int> i(maxd);
|
||||
static std::vector<Vertex_handle> w(maxd);
|
||||
# endif
|
||||
int d;
|
||||
remove_degree_init(v,f,w,i,d,maxd);
|
||||
remove_degree_triangulate(v,f,w,i,d);
|
||||
|
|
@ -1115,7 +1111,7 @@ remove(Vertex_handle v)
|
|||
if ( this->dimension() <= 1) { Triangulation::remove(v); return; }
|
||||
|
||||
#ifdef CGAL_HAS_THREADS
|
||||
#ifdef BOOST_MSVC
|
||||
#ifndef CGAL_USE_BOOST_THREAD
|
||||
CGAL_THREAD_LOCAL static int maxd = 30;
|
||||
|
||||
CGAL_THREAD_LOCAL static std::vector<Face_handle>* f_ptr;
|
||||
|
|
@ -2295,7 +2291,7 @@ move_if_no_collision(Vertex_handle v, const Point &p) {
|
|||
{
|
||||
int d;
|
||||
#ifdef CGAL_HAS_THREADS
|
||||
#ifdef BOOST_MSVC
|
||||
#ifndef CGAL_USE_BOOST_THREAD
|
||||
CGAL_THREAD_LOCAL static int maxd = 30;
|
||||
|
||||
CGAL_THREAD_LOCAL static std::vector<Face_handle>* f_ptr;
|
||||
|
|
@ -2546,7 +2542,7 @@ move_if_no_collision_and_give_new_faces(Vertex_handle v,
|
|||
|
||||
{
|
||||
#ifdef CGAL_HAS_THREADS
|
||||
#ifdef BOOST_MSVC
|
||||
#ifndef CGAL_USE_BOOST_THREAD
|
||||
CGAL_THREAD_LOCAL static int maxd = 30;
|
||||
|
||||
CGAL_THREAD_LOCAL static std::vector<Face_handle>* f_ptr;
|
||||
|
|
|
|||
Loading…
Reference in New Issue