File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed
rclcpp/src/rclcpp/executors Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments