Synchronize correctly in FinishTrajectory(). (#980)

PoseGraph{2D,3D}::FinishTrajectory() calls AddWorkItem() which
requires the mutex to be held. This adds code to do this.
master
Wolfgang Hess 2018-03-13 14:10:51 +01:00 committed by Wally B. Feed
parent 525f7afe7e
commit c09b643d8d
2 changed files with 2 additions and 0 deletions

View File

@ -392,6 +392,7 @@ void PoseGraph2D::WaitForAllComputations() {
} }
void PoseGraph2D::FinishTrajectory(const int trajectory_id) { void PoseGraph2D::FinishTrajectory(const int trajectory_id) {
common::MutexLocker locker(&mutex_);
AddWorkItem([this, trajectory_id]() REQUIRES(mutex_) { AddWorkItem([this, trajectory_id]() REQUIRES(mutex_) {
CHECK_EQ(finished_trajectories_.count(trajectory_id), 0); CHECK_EQ(finished_trajectories_.count(trajectory_id), 0);
finished_trajectories_.insert(trajectory_id); finished_trajectories_.insert(trajectory_id);

View File

@ -410,6 +410,7 @@ void PoseGraph3D::WaitForAllComputations() {
} }
void PoseGraph3D::FinishTrajectory(const int trajectory_id) { void PoseGraph3D::FinishTrajectory(const int trajectory_id) {
common::MutexLocker locker(&mutex_);
AddWorkItem([this, trajectory_id]() REQUIRES(mutex_) { AddWorkItem([this, trajectory_id]() REQUIRES(mutex_) {
CHECK_EQ(finished_trajectories_.count(trajectory_id), 0); CHECK_EQ(finished_trajectories_.count(trajectory_id), 0);
finished_trajectories_.insert(trajectory_id); finished_trajectories_.insert(trajectory_id);