Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(StaticSingleThreadedExecutor): Fixed regression in spin() #2473

Open
wants to merge 1 commit into
base: rolling
Choose a base branch
from
Open
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
18 changes: 13 additions & 5 deletions rclcpp/src/rclcpp/executors/static_single_threaded_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,19 @@ StaticSingleThreadedExecutor::spin()
}
RCPPUTILS_SCOPE_EXIT(this->spinning.store(false); );

// This is essentially the contents of the rclcpp::Executor::wait_for_work method,
// except we need to keep the wait result to reproduce the StaticSingleThreadedExecutor
// behavior.
while (rclcpp::ok(this->context_) && spinning.load()) {
this->spin_once_impl(std::chrono::nanoseconds(-1));
while (rclcpp::ok(context_) && spinning.load()) {
// Get executables that are ready now
std::lock_guard<std::mutex> guard(mutex_);
jmachowinski marked this conversation as resolved.
Show resolved Hide resolved

// wait forever until the wait returns
auto wait_result = this->collect_and_wait(std::chrono::nanoseconds(-1));
if (wait_result.has_value()) {
// Execute ready executables
this->execute_ready_executables(
current_collection_,
wait_result.value(),
false);
}
}
}

Expand Down