Merge pull request #1497 from afabri/Circular_kernel_2-static-GF

Circular_kernel_2: Use thread local storage
This commit is contained in:
Laurent Rineau 2016-10-17 10:01:14 +02:00
commit c24a2a3347
1 changed files with 24 additions and 24 deletions

View File

@ -42,7 +42,8 @@
#include <CGAL/intersections.h>
#include <CGAL/Circular_kernel_2/Intersection_traits.h>
#include <CGAL/result_of.h>
#include <CGAL/tss.h>
namespace CGAL {
namespace internal {
@ -334,7 +335,11 @@ namespace internal {
unsigned int my_id; // the id of the arc
// to optimize make_x_monotone and splits
// so we have not echec de filtre for intersection
static Table table;
static Table& table()
{
CGAL_STATIC_THREAD_LOCAL_VARIABLE(Table, table_, );
return table_;
}
#endif
public:
@ -344,19 +349,25 @@ namespace internal {
static bool find_intersection(const Circular_arc_2_base& c1,
const Circular_arc_2_base& c2,
T& res) {
return table.find<T>(c1.my_id, c2.my_id, res);
return Circular_arc_2_base::table().find<T>(c1.my_id, c2.my_id, res);
}
template < class T >
static void put_intersection(const Circular_arc_2_base& c1,
const Circular_arc_2_base& c2,
const T& res) {
table.put<T>(c1.my_id, c2.my_id, res);
Circular_arc_2_base::table().put<T>(c1.my_id, c2.my_id, res);
}
#endif
#ifdef CGAL_INTERSECTION_MAP_FOR_SUPPORTING_CIRCLES
static Table circle_table;
static Table& circle_table()
{
CGAL_STATIC_THREAD_LOCAL_VARIABLE(Table, circle_table_, );
return circle_table_;
}
mutable unsigned int id_of_my_supporting_circle;
template < class T >
@ -366,18 +377,18 @@ namespace internal {
T& res) {
if(c1.id_of_my_supporting_circle == 0) return false;
if(c2.id_of_my_supporting_circle == 0) return false;
return circle_table.find<T>(c1.id_of_my_supporting_circle,
c2.id_of_my_supporting_circle,
res);
return Circular_arc_2_base::circle_table().find<T>(c1.id_of_my_supporting_circle,
c2.id_of_my_supporting_circle,
res);
}
template < class T >
static void put_intersection_circle_circle(const Circular_arc_2_base& c1,
const Circular_arc_2_base& c2,
const T& res) {
circle_table.put<T>(c1.circle_number(),
c2.circle_number(),
res);
Circular_arc_2_base::circle_table().put<T>(c1.circle_number(),
c2.circle_number(),
res);
}
#endif
@ -418,7 +429,7 @@ private:
#ifdef CGAL_INTERSECTION_MAP_FOR_XMONOTONIC_ARC_WITH_SAME_SUPPORTING_CIRCLE
void _get_id_number() {
my_id = table.get_new_id();
my_id = table().get_new_id();
}
#endif
@ -619,7 +630,7 @@ public:
#ifdef CGAL_INTERSECTION_MAP_FOR_SUPPORTING_CIRCLES
unsigned int circle_number() const {
if(!id_of_my_supporting_circle)
id_of_my_supporting_circle = circle_table.get_new_id();
id_of_my_supporting_circle = circle_table().get_new_id();
return id_of_my_supporting_circle;
}
@ -661,17 +672,6 @@ public:
}; // end class Circular_arc_2_base
#ifdef CGAL_INTERSECTION_MAP_FOR_XMONOTONIC_ARC_WITH_SAME_SUPPORTING_CIRCLE
template < typename CK >
internal::Intersection_line_2_circle_2_map Circular_arc_2_base< CK >::table =
internal::Intersection_line_2_circle_2_map();
#endif
#ifdef CGAL_INTERSECTION_MAP_FOR_SUPPORTING_CIRCLES
template < typename CK >
internal::Intersection_line_2_circle_2_map Circular_arc_2_base< CK >::circle_table =
internal::Intersection_line_2_circle_2_map();
#endif
template < typename CK >
std::ostream &