Moved mutex around smaller block
parent
5c406dc7c7
commit
c8cf14d4b9
|
@ -69,18 +69,13 @@ Unit3 Unit3::Random(boost::mt19937 & rng) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef GTSAM_USE_TBB
|
#ifdef GTSAM_USE_TBB
|
||||||
tbb::mutex unit3BasisMutex;
|
static tbb::mutex unit3BasisMutex;
|
||||||
#endif
|
#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_) return *B_;
|
||||||
return *B_;
|
|
||||||
|
|
||||||
// Get the axis of rotation with the minimum projected length of the point
|
// Get the axis of rotation with the minimum projected length of the point
|
||||||
Vector3 axis;
|
Vector3 axis;
|
||||||
|
@ -99,8 +94,13 @@ const Matrix32& Unit3::basis() const {
|
||||||
Vector3 b2 = p_.cross(b1).normalized();
|
Vector3 b2 = p_.cross(b1).normalized();
|
||||||
|
|
||||||
// Create the basis matrix
|
// Create the basis matrix
|
||||||
B_.reset(Matrix32());
|
{
|
||||||
(*B_) << b1, b2;
|
#ifdef GTSAM_USE_TBB
|
||||||
|
tbb::mutex::scoped_lock lock(unit3BasisMutex);
|
||||||
|
#endif
|
||||||
|
B_.reset(Matrix32());
|
||||||
|
(*B_) << b1, b2;
|
||||||
|
}
|
||||||
return *B_;
|
return *B_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue