From 80db8108553fcdbe1f9c917dbab5f4327337fe91 Mon Sep 17 00:00:00 2001 From: cbeall3 Date: Fri, 13 Feb 2015 16:04:20 -0500 Subject: [PATCH] Thread-safe access to Unit3::basis() when TBB is on --- gtsam/geometry/Unit3.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gtsam/geometry/Unit3.cpp b/gtsam/geometry/Unit3.cpp index 415410aa4..be48aecc9 100644 --- a/gtsam/geometry/Unit3.cpp +++ b/gtsam/geometry/Unit3.cpp @@ -31,6 +31,10 @@ # pragma clang diagnostic pop #endif +#ifdef GTSAM_USE_TBB +#include +#endif + #include #include @@ -65,8 +69,15 @@ Unit3 Unit3::Random(boost::mt19937 & rng) { return result; } +#ifdef GTSAM_USE_TBB +tbb::mutex unit3BasisMutex; +#endif + /* ************************************************************************* */ const Matrix32& Unit3::basis() const { +#ifdef GTSAM_USE_TBB + tbb::mutex::scoped_lock lock(unit3BasisMutex); +#endif // Return cached version if exists if (B_)