Thread-safe access to Unit3::basis() when TBB is on
parent
91ea8e3bd7
commit
80db810855
|
@ -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_)
|
||||||
|
|
Loading…
Reference in New Issue