From 939de5f68004a08cbac1b45e10d10c0ce3327b7e Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 31 Aug 2016 16:50:20 +0200 Subject: [PATCH] Make variables thread local or they are const as read only --- .../include/CGAL/Segment_Delaunay_graph_2.h | 4 +++- .../CGAL/Segment_Delaunay_graph_2/Basic_predicates_C2.h | 8 ++++---- .../CGAL/Segment_Delaunay_graph_2/Cartesian_converter.h | 2 +- .../Segment_Delaunay_graph_hierarchy_2_impl.h | 6 +++--- .../Triangulation_face_base_with_edges_2.h | 2 +- .../include/CGAL/Segment_Delaunay_graph_2/edge_list.h | 8 ++++---- .../CGAL/Segment_Delaunay_graph_2/in_place_edge_list.h | 2 +- .../include/CGAL/Segment_Delaunay_graph_face_base_2.h | 2 +- 8 files changed, 18 insertions(+), 16 deletions(-) diff --git a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2.h b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2.h index 39d88af72ee..b7a23c23438 100644 --- a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2.h +++ b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2.h @@ -50,6 +50,8 @@ #include #include +#include + #include /* @@ -1427,7 +1429,7 @@ protected: void print_error_message(const Tag_false&) const { - static int i = 0; + CGAL_STATIC_THREAD_LOCAL_VARIABLE(int, i, 0); if ( i == 0 ) { i++; diff --git a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Basic_predicates_C2.h b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Basic_predicates_C2.h index 78355ed49c4..9a7f47ecd45 100644 --- a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Basic_predicates_C2.h +++ b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Basic_predicates_C2.h @@ -66,13 +66,13 @@ public: typedef Boolean_tag::value> RT_Has_sqrt; typedef Boolean_tag::value> FT_Has_sqrt; - static const RT_Has_sqrt& rt_has_sqrt() { - static RT_Has_sqrt has_sqrt; + static RT_Has_sqrt rt_has_sqrt() { + RT_Has_sqrt has_sqrt; return has_sqrt; } - static const FT_Has_sqrt& ft_has_sqrt() { - static FT_Has_sqrt has_sqrt; + static FT_Has_sqrt ft_has_sqrt() { + FT_Has_sqrt has_sqrt; return has_sqrt; } diff --git a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Cartesian_converter.h b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Cartesian_converter.h index ec30ea8e409..fa47a7182e1 100644 --- a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Cartesian_converter.h +++ b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Cartesian_converter.h @@ -48,7 +48,7 @@ private: private: static const Intersections_tag& intersections_tag() { - static Intersections_tag itag; + static const Intersections_tag itag; return itag; } diff --git a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_hierarchy_2_impl.h b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_hierarchy_2_impl.h index 9602cfac6ad..313148cdf9c 100644 --- a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_hierarchy_2_impl.h +++ b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_hierarchy_2_impl.h @@ -352,7 +352,7 @@ insert_segment(const Point_2& p0, const Point_2& p1, Vertex_handle vertex; if ( hierarchy[0]->number_of_vertices() == 2 ) { - static Segments_in_hierarchy_tag stag; + static const Segments_in_hierarchy_tag stag; vertex = hierarchy[0]->insert_third(ss, vertices0[0], vertices1[0]); insert_segment_in_upper_levels(t, vertex->storage_site(), @@ -382,8 +382,8 @@ insert_segment_interior(const Site_2& t, const Storage_site_2& ss, // arrangement_type // the tags - static Intersections_tag itag; - static Segments_in_hierarchy_tag stag; + static const Intersections_tag itag; + static const Segments_in_hierarchy_tag stag; // find the first conflict diff --git a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Triangulation_face_base_with_edges_2.h b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Triangulation_face_base_with_edges_2.h index a0ad714de42..9c4b12d7b9a 100644 --- a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Triangulation_face_base_with_edges_2.h +++ b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Triangulation_face_base_with_edges_2.h @@ -128,7 +128,7 @@ protected: static int sentinel_index() { return -1; } static const Edge& sentinel_edge() { - static Edge SENTINEL_EDGE = Edge(Face_handle(), sentinel_index()); + static const Edge SENTINEL_EDGE = Edge(Face_handle(), sentinel_index()); return SENTINEL_EDGE; } diff --git a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/edge_list.h b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/edge_list.h index e092663d4d7..fe9d433c5df 100644 --- a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/edge_list.h +++ b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/edge_list.h @@ -48,7 +48,7 @@ namespace internal { // remove the following method and make SENTINEL_EDGE a static const // member of the class. static const Edge& sentinel_edge() { - static Edge SENTINEL_EDGE = Edge(Face_handle(), sentinel_index()); + static const Edge SENTINEL_EDGE = Edge(Face_handle(), sentinel_index()); return SENTINEL_EDGE; } @@ -389,7 +389,7 @@ public: bool is_valid() const { return true; } bool is_in_list(const Edge& e) const { - static Use_stl_map_tag map_tag; + Use_stl_map_tag map_tag; return is_in_list_with_tag(e, map_tag); } @@ -402,13 +402,13 @@ public: const Edge& next(const Edge& e) const { CGAL_precondition( is_in_list(e) ); - static Use_stl_map_tag map_tag; + Use_stl_map_tag map_tag; return next_with_tag(e, map_tag); } const Edge& previous(const Edge& e) const { CGAL_precondition( is_in_list(e) ); - static Use_stl_map_tag map_tag; + Use_stl_map_tag map_tag; return previous_with_tag(e, map_tag); } diff --git a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/in_place_edge_list.h b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/in_place_edge_list.h index 71f770574b3..f47433ef51b 100644 --- a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/in_place_edge_list.h +++ b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/in_place_edge_list.h @@ -243,7 +243,7 @@ public: void remove(const Edge& e) { CGAL_precondition( is_in_list(e) ); - static Edge SENTINEL_QUEUE_EDGE = Edge(Face_handle(), -1); + static const Edge SENTINEL_QUEUE_EDGE = Edge(Face_handle(), -1); if ( is_singleton() ) { _front = SENTINEL_QUEUE_EDGE; diff --git a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_face_base_2.h b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_face_base_2.h index 66b9c57d378..0ca56e6c5b9 100644 --- a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_face_base_2.h +++ b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_face_base_2.h @@ -64,7 +64,7 @@ private: // method to initialize the in-place edge list void initialize_in_place_edge_list() { - static Edge SENTINEL_QUEUE_EDGE = Edge(Face_handle(), -1); + static const Edge SENTINEL_QUEUE_EDGE = Edge(Face_handle(), -1); for (int i = 0; i < 3; ++i) { selected[i] = false;