Check if context is valid when looping in spin_some (#1167)

Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
This commit is contained in:
Ivan Santiago Paunovic 2020-06-11 17:17:39 -03:00
parent 70e1830ecd
commit c14f46e6f3

View file

@ -234,7 +234,7 @@ Executor::spin_some(std::chrono::nanoseconds max_duration)
RCLCPP_SCOPE_EXIT(this->spinning.store(false); ); RCLCPP_SCOPE_EXIT(this->spinning.store(false); );
// non-blocking call to pre-load all available work // non-blocking call to pre-load all available work
wait_for_work(std::chrono::milliseconds::zero()); wait_for_work(std::chrono::milliseconds::zero());
while (spinning.load() && max_duration_not_elapsed()) { while (rclcpp::ok(context_) && spinning.load() && max_duration_not_elapsed()) {
AnyExecutable any_exec; AnyExecutable any_exec;
if (get_next_ready_executable(any_exec)) { if (get_next_ready_executable(any_exec)) {
execute_any_executable(any_exec); execute_any_executable(any_exec);