Rename timer `Setup` function to `Schedule`
This patch was motivated by my desire to fix a typo in the function
name. The noun "setup" is 1 word. The verb "set up" is 2 words. All
other member functions are verbs, so this one should be a verb too.
That means that the function should be called `SetUp`. During the
discussion that resulted from the rename, James Kuszmaul pointed out
that "setting up" a timer can be confusing. It implies that you can
only "set up" a timer once. But the intent is to let users set up
timers as many times as they like. So we decided on renaming the
function to `Schedule`. That conveys the purpose and intent better.
I took this opportunity to fix some other typos involving the verb
"set up".
Signed-off-by: Philipp Schrader <philipp.schrader@gmail.com>
Change-Id: I2f557d1f946960af82711f248820d5e2d385a5d3
diff --git a/y2023/autonomous/autonomous_actor.cc b/y2023/autonomous/autonomous_actor.cc
index e1b4e1d..bedbab7 100644
--- a/y2023/autonomous/autonomous_actor.cc
+++ b/y2023/autonomous/autonomous_actor.cc
@@ -61,8 +61,9 @@
replan_timer_ = event_loop->AddTimer([this]() { Replan(); });
event_loop->OnRun([this, event_loop]() {
- replan_timer_->Setup(event_loop->monotonic_now());
- button_poll_->Setup(event_loop->monotonic_now(), chrono::milliseconds(50));
+ replan_timer_->Schedule(event_loop->monotonic_now());
+ button_poll_->Schedule(event_loop->monotonic_now(),
+ chrono::milliseconds(50));
});
// TODO(james): Really need to refactor this code since we keep using it.
@@ -83,12 +84,12 @@
// Only kick the planning out by 2 seconds. If we end up enabled in
// that second, then we will kick it out further based on the code
// below.
- replan_timer_->Setup(now + std::chrono::seconds(2));
+ replan_timer_->Schedule(now + std::chrono::seconds(2));
}
if (joystick_state_fetcher_->enabled()) {
if (!is_planned_) {
// Only replan once we've been disabled for 5 seconds.
- replan_timer_->Setup(now + std::chrono::seconds(5));
+ replan_timer_->Schedule(now + std::chrono::seconds(5));
}
}
}
@@ -97,7 +98,7 @@
void AutonomousActor::Replan() {
if (!drivetrain_status_fetcher_.Fetch()) {
- replan_timer_->Setup(event_loop()->monotonic_now() + chrono::seconds(1));
+ replan_timer_->Schedule(event_loop()->monotonic_now() + chrono::seconds(1));
AOS_LOG(INFO, "Drivetrain not up, replanning in 1 second");
return;
}