Skip to content

Commit

Permalink
Reset timer trigger time before execute. (#1739)
Browse files Browse the repository at this point in the history
This PR fixes an issue with StaticSingleThreadedExecutor
not reseting the timers, so they were always ready
and executing callbacks continuosly.

#1692

Signed-off-by: Mauro Passerino <mpasserino@irobot.com>
  • Loading branch information
mauropasse authored Aug 9, 2021
1 parent 3b1144f commit b918bd4
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <chrono>
#include <memory>
#include <utility>
#include <vector>

#include "rcpputils/scope_exit.hpp"
Expand Down Expand Up @@ -237,7 +238,9 @@ StaticSingleThreadedExecutor::execute_ready_executables(bool spin_once)
for (size_t i = 0; i < wait_set_.size_of_timers; ++i) {
if (i < entities_collector_->get_number_of_timers()) {
if (wait_set_.timers[i] && entities_collector_->get_timer(i)->is_ready()) {
execute_timer(entities_collector_->get_timer(i));
auto timer = entities_collector_->get_timer(i);
timer->call();
execute_timer(std::move(timer));
if (spin_once) {
return true;
}
Expand Down

0 comments on commit b918bd4

Please sign in to comment.