fix possible race condition per ticket #3802

git-svn-id: https://code.ros.org/svn/ros-pkg/stacks/laser_pipeline/trunk@27698 eb33c2ac-9c88-4c90-87e0-44a10359b0c3
This commit is contained in:
John Hsu 2010-02-09 00:50:38 +00:00
parent 735e86948f
commit 81bcc63259
2 changed files with 4 additions and 0 deletions

View File

@ -35,6 +35,7 @@
#include <sstream> #include <sstream>
#include "boost/numeric/ublas/matrix.hpp" #include "boost/numeric/ublas/matrix.hpp"
#include "boost/thread/mutex.hpp"
#include "tf/tf.h" #include "tf/tf.h"
@ -234,6 +235,7 @@ namespace laser_geometry
//! Internal map of pointers to stored values //! Internal map of pointers to stored values
std::map<std::string,boost::numeric::ublas::matrix<double>* > unit_vector_map_; std::map<std::string,boost::numeric::ublas::matrix<double>* > unit_vector_map_;
boost::mutex guv_mutex_;
}; };
} }

View File

@ -152,6 +152,8 @@ namespace laser_geometry
const boost::numeric::ublas::matrix<double>& LaserProjection::getUnitVectors_(double angle_min, double angle_max, double angle_increment, unsigned int length) const boost::numeric::ublas::matrix<double>& LaserProjection::getUnitVectors_(double angle_min, double angle_max, double angle_increment, unsigned int length)
{ {
boost::mutex::scoped_lock guv_lock(this->guv_mutex_);
//construct string for lookup in the map //construct string for lookup in the map
std::stringstream anglestring; std::stringstream anglestring;
anglestring <<angle_min<<","<<angle_max<<","<<angle_increment<<","<<length; anglestring <<angle_min<<","<<angle_max<<","<<angle_increment<<","<<length;