From eb6586dc70f7ffd1b7771e8b9532d9316beb9b30 Mon Sep 17 00:00:00 2001 From: jwang Date: Thu, 11 Jan 2018 18:56:51 +0800 Subject: [PATCH 1/2] Move clear wait set from after rcl_wait to ahead Current code clear wait set after rcl_wait, it is not respond latency friendly. In fact, clear wait set operation is not urgent, making sure it is done before next rcl_wait should be fine. Signed-off-by: jwang --- rclcpp/src/rclcpp/executor.cpp | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/rclcpp/src/rclcpp/executor.cpp b/rclcpp/src/rclcpp/executor.cpp index c03a9f2f98..95870afafd 100644 --- a/rclcpp/src/rclcpp/executor.cpp +++ b/rclcpp/src/rclcpp/executor.cpp @@ -376,6 +376,22 @@ Executor::wait_for_work(std::chrono::nanoseconds timeout) ) ); } + // clear wait set + if (rcl_wait_set_clear_subscriptions(&wait_set_) != RCL_RET_OK) { + throw std::runtime_error("Couldn't clear subscriptions from wait set"); + } + if (rcl_wait_set_clear_services(&wait_set_) != RCL_RET_OK) { + throw std::runtime_error("Couldn't clear servicess from wait set"); + } + if (rcl_wait_set_clear_clients(&wait_set_) != RCL_RET_OK) { + throw std::runtime_error("Couldn't clear clients from wait set"); + } + if (rcl_wait_set_clear_guard_conditions(&wait_set_) != RCL_RET_OK) { + throw std::runtime_error("Couldn't clear guard conditions from wait set"); + } + if (rcl_wait_set_clear_timers(&wait_set_) != RCL_RET_OK) { + throw std::runtime_error("Couldn't clear timers from wait set"); + } if (rcl_wait_set_resize_subscriptions( &wait_set_, memory_strategy_->number_of_ready_subscriptions()) != RCL_RET_OK) @@ -432,21 +448,6 @@ Executor::wait_for_work(std::chrono::nanoseconds timeout) // check the null handles in the wait set and remove them from the handles in memory strategy // for callback-based entities memory_strategy_->remove_null_handles(&wait_set_); - if (rcl_wait_set_clear_subscriptions(&wait_set_) != RCL_RET_OK) { - throw std::runtime_error("Couldn't clear subscriptions from wait set"); - } - if (rcl_wait_set_clear_services(&wait_set_) != RCL_RET_OK) { - throw std::runtime_error("Couldn't clear servicess from wait set"); - } - if (rcl_wait_set_clear_clients(&wait_set_) != RCL_RET_OK) { - throw std::runtime_error("Couldn't clear clients from wait set"); - } - if (rcl_wait_set_clear_guard_conditions(&wait_set_) != RCL_RET_OK) { - throw std::runtime_error("Couldn't clear guard conditions from wait set"); - } - if (rcl_wait_set_clear_timers(&wait_set_) != RCL_RET_OK) { - throw std::runtime_error("Couldn't clear timers from wait set"); - } } rclcpp::node_interfaces::NodeBaseInterface::SharedPtr From 77ab3bc22df19b106741640a1b10c8028ade7e8c Mon Sep 17 00:00:00 2001 From: William Woodall Date: Thu, 18 Jan 2018 16:59:20 -0800 Subject: [PATCH 2/2] remove trailing whitespace --- rclcpp/src/rclcpp/executor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rclcpp/src/rclcpp/executor.cpp b/rclcpp/src/rclcpp/executor.cpp index 95870afafd..eb31da6692 100644 --- a/rclcpp/src/rclcpp/executor.cpp +++ b/rclcpp/src/rclcpp/executor.cpp @@ -376,7 +376,7 @@ Executor::wait_for_work(std::chrono::nanoseconds timeout) ) ); } - // clear wait set + // clear wait set if (rcl_wait_set_clear_subscriptions(&wait_set_) != RCL_RET_OK) { throw std::runtime_error("Couldn't clear subscriptions from wait set"); }