summaryrefslogtreecommitdiff
path: root/src/Nerve_GIC
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-06-07 09:29:16 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-06-07 09:29:16 +0000
commit1ab1ffb38c49443ebef69dbb86e5da582c1cd767 (patch)
treee491fdc41dcf162b66381da6463bf357f972c386 /src/Nerve_GIC
parent0886a06c75d43f6e9d64f41440c0f1c6fd02c06a (diff)
Code review : Use thread_local when necessary
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@3558 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 0893cfa1065dcd9988c9d910e764b7a1edbcdc11
Diffstat (limited to 'src/Nerve_GIC')
-rw-r--r--src/Nerve_GIC/include/gudhi/GIC.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/Nerve_GIC/include/gudhi/GIC.h b/src/Nerve_GIC/include/gudhi/GIC.h
index ebe463dd..7aa95210 100644
--- a/src/Nerve_GIC/include/gudhi/GIC.h
+++ b/src/Nerve_GIC/include/gudhi/GIC.h
@@ -142,17 +142,25 @@ class Cover_complex {
std::string point_cloud_name;
std::string color_name;
- // 2 threads using 2 different GIC will have their own random engine
- std::default_random_engine re;
-
// Remove all edges of a graph.
void remove_edges(Graph& G) {
boost::graph_traits<Graph>::edge_iterator ei, ei_end;
for (boost::tie(ei, ei_end) = boost::edges(G); ei != ei_end; ++ei) boost::remove_edge(*ei, G);
}
+ // Thread local is not available on XCode version < V.8
+ // If not available, random engine is a class member.
+#ifndef GUDHI_CAN_USE_CXX11_THREAD_LOCAL
+ std::default_random_engine re;
+#endif // GUDHI_CAN_USE_CXX11_THREAD_LOCAL
+
// Find random number in [0,1].
double GetUniform() {
+ // Thread local is not available on XCode version < V.8
+ // If available, random engine is defined for each thread.
+#ifdef GUDHI_CAN_USE_CXX11_THREAD_LOCAL
+ thread_local std::default_random_engine re;
+#endif // GUDHI_CAN_USE_CXX11_THREAD_LOCAL
std::uniform_real_distribution<double> Dist(0, 1);
return Dist(re);
}