Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions rclcpp_lifecycle/test/test_lifecycle_service_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <gtest/gtest.h>
#include <chrono>
#include <memory>
#include <mutex>
#include <string>
#include <thread>
#include <vector>
Expand Down Expand Up @@ -217,21 +218,31 @@ class TestLifecycleServiceClient : public ::testing::Test

void TearDown() override
{
rclcpp::shutdown();
{
std::lock_guard<std::mutex> guard(shutdown_mutex_);
rclcpp::shutdown();
}
spinner_.join();
}

void spin()
{
while (rclcpp::ok()) {
rclcpp::spin_some(lifecycle_node_->get_node_base_interface());
rclcpp::spin_some(lifecycle_client_);
while (true) {
{
std::lock_guard<std::mutex> guard(shutdown_mutex_);
if (!rclcpp::ok()) {
break;
}
rclcpp::spin_some(lifecycle_node_->get_node_base_interface());
rclcpp::spin_some(lifecycle_client_);
}
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}

std::shared_ptr<EmptyLifecycleNode> lifecycle_node_;
std::shared_ptr<LifecycleServiceClient> lifecycle_client_;
std::mutex shutdown_mutex_;
std::thread spinner_;
};

Expand Down