From 7422cda6c66ad1eae1dbfc511f431db236eb5a0a Mon Sep 17 00:00:00 2001 From: Tully Foote Date: Thu, 17 Dec 2015 11:07:00 -0800 Subject: [PATCH 1/2] remove excess sleep identified in #169 --- rclcpp/src/rclcpp/executors/multi_threaded_executor.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/rclcpp/src/rclcpp/executors/multi_threaded_executor.cpp b/rclcpp/src/rclcpp/executors/multi_threaded_executor.cpp index d419ffd..0be93f8 100644 --- a/rclcpp/src/rclcpp/executors/multi_threaded_executor.cpp +++ b/rclcpp/src/rclcpp/executors/multi_threaded_executor.cpp @@ -46,7 +46,6 @@ MultiThreadedExecutor::spin() { std::lock_guard wait_lock(wait_mutex_); for (; thread_id < number_of_threads_ - 1; ++thread_id) { - std::this_thread::sleep_for(std::chrono::milliseconds(100)); auto func = std::bind(&MultiThreadedExecutor::run, this, thread_id); threads.emplace_back(func); } From a7a61119fd749aae2464fe444c920b2c9915c404 Mon Sep 17 00:00:00 2001 From: Brian Gerkey Date: Thu, 17 Dec 2015 19:06:28 -0800 Subject: [PATCH 2/2] remove unused data structure for which unprotected concurrent access was causing segfaults and deadlocks on OSX --- rclcpp/include/rclcpp/executors/multi_threaded_executor.hpp | 1 - rclcpp/src/rclcpp/executors/multi_threaded_executor.cpp | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/rclcpp/include/rclcpp/executors/multi_threaded_executor.hpp b/rclcpp/include/rclcpp/executors/multi_threaded_executor.hpp index 30ca1b0..9eb78a1 100644 --- a/rclcpp/include/rclcpp/executors/multi_threaded_executor.hpp +++ b/rclcpp/include/rclcpp/executors/multi_threaded_executor.hpp @@ -61,7 +61,6 @@ private: std::mutex wait_mutex_; size_t number_of_threads_; - std::unordered_map thread_number_by_thread_id_; }; } // namespace multi_threaded_executor diff --git a/rclcpp/src/rclcpp/executors/multi_threaded_executor.cpp b/rclcpp/src/rclcpp/executors/multi_threaded_executor.cpp index 0be93f8..1be631a 100644 --- a/rclcpp/src/rclcpp/executors/multi_threaded_executor.cpp +++ b/rclcpp/src/rclcpp/executors/multi_threaded_executor.cpp @@ -64,9 +64,8 @@ MultiThreadedExecutor::get_number_of_threads() } void -MultiThreadedExecutor::run(size_t this_thread_number) +MultiThreadedExecutor::run(size_t) { - thread_number_by_thread_id_[std::this_thread::get_id()] = this_thread_number; while (rclcpp::utilities::ok() && spinning.load()) { executor::AnyExecutable::SharedPtr any_exec; {