Make variables thread local or they are const as read only

This commit is contained in:
Andreas Fabri 2016-08-31 16:50:20 +02:00
parent 641d5d51ef
commit 939de5f680
8 changed files with 18 additions and 16 deletions

View File

@ -50,6 +50,8 @@
#include <CGAL/spatial_sort.h> #include <CGAL/spatial_sort.h>
#include <CGAL/Spatial_sort_traits_adapter_2.h> #include <CGAL/Spatial_sort_traits_adapter_2.h>
#include <CGAL/tss.h>
#include <boost/iterator/counting_iterator.hpp> #include <boost/iterator/counting_iterator.hpp>
/* /*
@ -1427,7 +1429,7 @@ protected:
void print_error_message(const Tag_false&) const void print_error_message(const Tag_false&) const
{ {
static int i = 0; CGAL_STATIC_THREAD_LOCAL_VARIABLE(int, i, 0);
if ( i == 0 ) { if ( i == 0 ) {
i++; i++;

View File

@ -66,13 +66,13 @@ public:
typedef Boolean_tag<CGAL::is_same_or_derived<Field_with_sqrt_tag,RT_Category>::value> RT_Has_sqrt; typedef Boolean_tag<CGAL::is_same_or_derived<Field_with_sqrt_tag,RT_Category>::value> RT_Has_sqrt;
typedef Boolean_tag<CGAL::is_same_or_derived<Field_with_sqrt_tag,FT_Category>::value> FT_Has_sqrt; typedef Boolean_tag<CGAL::is_same_or_derived<Field_with_sqrt_tag,FT_Category>::value> FT_Has_sqrt;
static const RT_Has_sqrt& rt_has_sqrt() { static RT_Has_sqrt rt_has_sqrt() {
static RT_Has_sqrt has_sqrt; RT_Has_sqrt has_sqrt;
return has_sqrt; return has_sqrt;
} }
static const FT_Has_sqrt& ft_has_sqrt() { static FT_Has_sqrt ft_has_sqrt() {
static FT_Has_sqrt has_sqrt; FT_Has_sqrt has_sqrt;
return has_sqrt; return has_sqrt;
} }

View File

@ -48,7 +48,7 @@ private:
private: private:
static const Intersections_tag& intersections_tag() static const Intersections_tag& intersections_tag()
{ {
static Intersections_tag itag; static const Intersections_tag itag;
return itag; return itag;
} }

View File

@ -352,7 +352,7 @@ insert_segment(const Point_2& p0, const Point_2& p1,
Vertex_handle vertex; Vertex_handle vertex;
if ( hierarchy[0]->number_of_vertices() == 2 ) { 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]); vertex = hierarchy[0]->insert_third(ss, vertices0[0], vertices1[0]);
insert_segment_in_upper_levels(t, vertex->storage_site(), 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 // arrangement_type
// the tags // the tags
static Intersections_tag itag; static const Intersections_tag itag;
static Segments_in_hierarchy_tag stag; static const Segments_in_hierarchy_tag stag;
// find the first conflict // find the first conflict

View File

@ -128,7 +128,7 @@ protected:
static int sentinel_index() { return -1; } static int sentinel_index() { return -1; }
static const Edge& sentinel_edge() { 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; return SENTINEL_EDGE;
} }

View File

@ -48,7 +48,7 @@ namespace internal {
// remove the following method and make SENTINEL_EDGE a static const // remove the following method and make SENTINEL_EDGE a static const
// member of the class. // member of the class.
static const Edge& sentinel_edge() { 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; return SENTINEL_EDGE;
} }
@ -389,7 +389,7 @@ public:
bool is_valid() const { return true; } bool is_valid() const { return true; }
bool is_in_list(const Edge& e) const { 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); return is_in_list_with_tag(e, map_tag);
} }
@ -402,13 +402,13 @@ public:
const Edge& next(const Edge& e) const { const Edge& next(const Edge& e) const {
CGAL_precondition( is_in_list(e) ); 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); return next_with_tag(e, map_tag);
} }
const Edge& previous(const Edge& e) const { const Edge& previous(const Edge& e) const {
CGAL_precondition( is_in_list(e) ); 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); return previous_with_tag(e, map_tag);
} }

View File

@ -243,7 +243,7 @@ public:
void remove(const Edge& e) { void remove(const Edge& e) {
CGAL_precondition( is_in_list(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() ) { if ( is_singleton() ) {
_front = SENTINEL_QUEUE_EDGE; _front = SENTINEL_QUEUE_EDGE;

View File

@ -64,7 +64,7 @@ private:
// method to initialize the in-place edge list // method to initialize the in-place edge list
void initialize_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) { for (int i = 0; i < 3; ++i) {
selected[i] = false; selected[i] = false;