Skip to content

Commit

Permalink
Wait for timeout if timeout < wait_tick_ns
Browse files Browse the repository at this point in the history
Signed-off-by: methylDragon <methylDragon@gmail.com>
  • Loading branch information
methylDragon committed Nov 3, 2022
1 parent c525133 commit 6face35
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion rclcpp/src/rclcpp/clock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,12 @@ Clock::wait_for_valid(
Time start = timeout_clock.now();

while (!is_valid() && context->is_valid()) { // Context check checks for rclcpp::shutdown()
timeout_clock.sleep_for(Duration(wait_tick_ns));
if (timeout < wait_tick_ns) {
timeout_clock.sleep_for(timeout);
} else {
timeout_clock.sleep_for(Duration(wait_tick_ns));
}

if (timeout_clock.now() - start > timeout) {
return is_valid();
}
Expand Down

0 comments on commit 6face35

Please sign in to comment.