Skip to content

Commit bb36ebb

Browse files
author
Janosch Machowinski
committed
fix(StaticSingleThreadedExecutor): Fixed regression in spin()
Signed-off-by: Janosch Machowinski <[email protected]>
1 parent f510db1 commit bb36ebb

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

rclcpp/src/rclcpp/executors/static_single_threaded_executor.cpp

+13-5
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,19 @@ StaticSingleThreadedExecutor::spin()
3535
}
3636
RCPPUTILS_SCOPE_EXIT(this->spinning.store(false); );
3737

38-
// This is essentially the contents of the rclcpp::Executor::wait_for_work method,
39-
// except we need to keep the wait result to reproduce the StaticSingleThreadedExecutor
40-
// behavior.
41-
while (rclcpp::ok(this->context_) && spinning.load()) {
42-
this->spin_once_impl(std::chrono::nanoseconds(-1));
38+
while (rclcpp::ok(context_) && spinning.load()) {
39+
// Get executables that are ready now
40+
std::lock_guard<std::mutex> guard(mutex_);
41+
42+
// wait forever until the wait returns
43+
auto wait_result = this->collect_and_wait(std::chrono::nanoseconds(-1));
44+
if (wait_result.has_value()) {
45+
// Execute ready executables
46+
this->execute_ready_executables(
47+
current_collection_,
48+
wait_result.value(),
49+
false);
50+
}
4351
}
4452
}
4553

0 commit comments

Comments
 (0)