From eb857624839329a9ad0683b2d8d1051480cc6b96 Mon Sep 17 00:00:00 2001 From: acxz <17132214+acxz@users.noreply.github.com> Date: Sat, 11 Jan 2020 13:09:16 -0500 Subject: [PATCH] change from deprecated tbb::mutex to std::mutex --- gtsam/base/debug.cpp | 16 ++++------------ gtsam/geometry/Unit3.cpp | 4 +--- gtsam/geometry/Unit3.h | 8 ++------ 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/gtsam/base/debug.cpp b/gtsam/base/debug.cpp index d6d2a4fe0..dbea53c7c 100644 --- a/gtsam/base/debug.cpp +++ b/gtsam/base/debug.cpp @@ -19,31 +19,23 @@ #include #include // for GTSAM_USE_TBB -#ifdef GTSAM_USE_TBB -#include -#endif +#include // std::mutex, std::unique_lock namespace gtsam { GTSAM_EXPORT FastMap > debugFlags; -#ifdef GTSAM_USE_TBB -tbb::mutex debugFlagsMutex; -#endif +std::mutex debugFlagsMutex; /* ************************************************************************* */ bool guardedIsDebug(const std::string& s) { -#ifdef GTSAM_USE_TBB - tbb::mutex::scoped_lock lock(debugFlagsMutex); -#endif + std::unique_lock lock(debugFlagsMutex); return gtsam::debugFlags[s]; } /* ************************************************************************* */ void guardedSetDebug(const std::string& s, const bool v) { -#ifdef GTSAM_USE_TBB - tbb::mutex::scoped_lock lock(debugFlagsMutex); -#endif + std::unique_lock lock(debugFlagsMutex); gtsam::debugFlags[s] = v; } diff --git a/gtsam/geometry/Unit3.cpp b/gtsam/geometry/Unit3.cpp index 533ee500e..655b94fc3 100644 --- a/gtsam/geometry/Unit3.cpp +++ b/gtsam/geometry/Unit3.cpp @@ -80,12 +80,10 @@ static Point3 CalculateBestAxis(const Point3& n) { /* ************************************************************************* */ const Matrix32& Unit3::basis(OptionalJacobian<6, 2> H) const { -#ifdef GTSAM_USE_TBB // NOTE(hayk): At some point it seemed like this reproducably resulted in // deadlock. However, I don't know why and I can no longer reproduce it. // It either was a red herring or there is still a latent bug left to debug. - tbb::mutex::scoped_lock lock(B_mutex_); -#endif + std::unique_lock lock(B_mutex_); const bool cachedBasis = static_cast(B_); const bool cachedJacobian = static_cast(H_B_); diff --git a/gtsam/geometry/Unit3.h b/gtsam/geometry/Unit3.h index 211698806..0a43ce59b 100644 --- a/gtsam/geometry/Unit3.h +++ b/gtsam/geometry/Unit3.h @@ -32,9 +32,7 @@ #include -#ifdef GTSAM_USE_TBB -#include -#endif +#include // std::mutex namespace gtsam { @@ -47,9 +45,7 @@ private: mutable boost::optional B_; ///< Cached basis mutable boost::optional H_B_; ///< Cached basis derivative -#ifdef GTSAM_USE_TBB - mutable tbb::mutex B_mutex_; ///< Mutex to protect the cached basis. -#endif + mutable std::mutex B_mutex_; ///< Mutex to protect the cached basis. public: