Thread-safe access to Unit3::basis() when TBB is on

release/4.3a0
cbeall3 2015-02-13 16:04:20 -05:00
parent 91ea8e3bd7
commit 80db810855
1 changed files with 11 additions and 0 deletions

View File

@ -31,6 +31,10 @@
# pragma clang diagnostic pop # pragma clang diagnostic pop
#endif #endif
#ifdef GTSAM_USE_TBB
#include <tbb/mutex.h>
#endif
#include <boost/random/variate_generator.hpp> #include <boost/random/variate_generator.hpp>
#include <iostream> #include <iostream>
@ -65,8 +69,15 @@ Unit3 Unit3::Random(boost::mt19937 & rng) {
return result; return result;
} }
#ifdef GTSAM_USE_TBB
tbb::mutex unit3BasisMutex;
#endif
/* ************************************************************************* */ /* ************************************************************************* */
const Matrix32& Unit3::basis() const { const Matrix32& Unit3::basis() const {
#ifdef GTSAM_USE_TBB
tbb::mutex::scoped_lock lock(unit3BasisMutex);
#endif
// Return cached version if exists // Return cached version if exists
if (B_) if (B_)