提交 1c3a798f 编写于 作者: L Liangliang Zhang 提交者: Jiaming Tao

Planning: fixed a threading bug in reference line provider.

上级 49fbd459
......@@ -147,7 +147,7 @@ void IntegrationTestBase::SetUp() {
Clock::SetMode(Clock::CYBERTRON);
apollo::cybertron::Init(node_name);
CHECK(FeedTestData()) << "Failed to feed test data";
// planning_.reset(new PlanningComponent());
planning_.reset(new PlanningComponent());
}
void IntegrationTestBase::UpdateData() {
......
......@@ -17,6 +17,7 @@
#include <map>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "gtest/gtest.h"
......
......@@ -26,8 +26,6 @@
#include <limits>
#include <utility>
#include "cybertron/cybertron.h"
#include "modules/common/configs/vehicle_config_helper.h"
#include "modules/common/time/time.h"
#include "modules/common/util/file.h"
......@@ -108,13 +106,20 @@ bool ReferenceLineProvider::Start() {
}
if (FLAGS_enable_reference_line_provider_thread) {
auto task = apollo::cybertron::CreateTask(
"async_reference_line_provider", [this]() { this->GenerateThread(); });
task_ = std::make_shared<apollo::cybertron::Task<int>>(
"async_reference_line_provider",
[this](const std::shared_ptr<int> &) { this->GenerateThread(); });
task_future_ = task_->Execute(std::make_shared<int>());
}
return true;
}
void ReferenceLineProvider::Stop() { is_stop_ = true; }
void ReferenceLineProvider::Stop() {
is_stop_ = true;
if (FLAGS_enable_reference_line_provider_thread) {
task_future_.get();
}
}
void ReferenceLineProvider::UpdateReferenceLine(
const std::list<ReferenceLine> &reference_lines,
......
......@@ -34,6 +34,8 @@
#include <unordered_set>
#include <vector>
#include "cybertron/cybertron.h"
#include "modules/common/vehicle_state/proto/vehicle_state.pb.h"
#include "modules/map/relative_map/proto/navigation.pb.h"
#include "modules/planning/proto/planning_config.pb.h"
......@@ -176,6 +178,9 @@ class ReferenceLineProvider {
std::queue<std::list<ReferenceLine>> reference_line_history_;
std::queue<std::list<hdmap::RouteSegments>> route_segments_history_;
std::shared_ptr<cybertron::Task<int>> task_;
std::future<void> task_future_;
};
} // namespace planning
......
......@@ -80,7 +80,9 @@ bool IsDifferentRouting(const RoutingResponse& first,
} // namespace
StdPlanning::~StdPlanning() {
reference_line_provider_->Stop();
if (reference_line_provider_) {
reference_line_provider_->Stop();
}
last_publishable_trajectory_.reset(nullptr);
frame_.reset(nullptr);
planner_.reset(nullptr);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册