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/aos/events/logging/log_reader.cc b/aos/events/logging/log_reader.cc
index f805c66..0e346a0 100644
--- a/aos/events/logging/log_reader.cc
+++ b/aos/events/logging/log_reader.cc
@@ -210,7 +210,7 @@
// Whops, time went backwards. Just do it now.
HandleTime();
} else {
- event_timer_->Setup(candidate_monotonic + clock_offset_);
+ event_timer_->Schedule(candidate_monotonic + clock_offset_);
}
}
@@ -1197,7 +1197,7 @@
}
// TODO(james): This can result in negative times getting passed-through
// in realtime replay.
- state->Setup(next_time.time);
+ state->Schedule(next_time.time);
} else {
VLOG(1) << MaybeNodeName(state->event_loop()->node())
<< "No next message, scheduling shutdown";
@@ -1208,8 +1208,8 @@
// Doesn't apply to single-EventLoop replay since the watchers in question
// are not under our control.
if (event_loop_factory_ != nullptr) {
- state->Setup(monotonic_now + event_loop_factory_->send_delay() +
- std::chrono::nanoseconds(1));
+ state->Schedule(monotonic_now + event_loop_factory_->send_delay() +
+ std::chrono::nanoseconds(1));
}
}
@@ -1241,8 +1241,8 @@
std::chrono::duration<double>(
FLAGS_threaded_look_ahead_seconds)));
state->MaybeSetClockOffset();
- state->Setup(next_time.time);
- state->SetupStartupTimer();
+ state->Schedule(next_time.time);
+ state->SetUpStartupTimer();
});
}
}
@@ -2101,7 +2101,7 @@
if (scheduled_time_ != remote_timestamps_.front().monotonic_timestamp_time) {
CHECK_NOTNULL(timer_);
- timer_->Setup(remote_timestamps_.front().monotonic_timestamp_time);
+ timer_->Schedule(remote_timestamps_.front().monotonic_timestamp_time);
scheduled_time_ = remote_timestamps_.front().monotonic_timestamp_time;
CHECK_GE(scheduled_time_, event_loop_->monotonic_now())
<< event_loop_->node()->name()->string_view();
diff --git a/aos/events/logging/log_reader.h b/aos/events/logging/log_reader.h
index 3bdfca4..fb6d6f9 100644
--- a/aos/events/logging/log_reader.h
+++ b/aos/events/logging/log_reader.h
@@ -471,7 +471,7 @@
// OldestMessageTime.
void SeedSortedMessages();
- void SetupStartupTimer() {
+ void SetUpStartupTimer() {
const monotonic_clock::time_point start_time =
monotonic_start_time(boot_count());
if (start_time == monotonic_clock::min_time) {
@@ -483,7 +483,7 @@
if (node_event_loop_factory_) {
CHECK_GE(start_time + clock_offset(), event_loop_->monotonic_now());
}
- startup_timer_->Setup(start_time + clock_offset());
+ startup_timer_->Schedule(start_time + clock_offset());
}
void set_startup_timer(TimerHandler *timer_handler) {
@@ -653,8 +653,8 @@
void ClearTimeFlags();
// Sets the next wakeup time on the replay callback.
- void Setup(monotonic_clock::time_point next_time) {
- timer_handler_->Setup(
+ void Schedule(monotonic_clock::time_point next_time) {
+ timer_handler_->Schedule(
std::max(monotonic_now(), next_time + clock_offset()));
}
diff --git a/aos/events/logging/log_writer.cc b/aos/events/logging/log_writer.cc
index 17c8da2..d129073 100644
--- a/aos/events/logging/log_writer.cc
+++ b/aos/events/logging/log_writer.cc
@@ -328,8 +328,8 @@
// logged without ordering concerns.
LogUntil(last_synchronized_time_);
- timer_handler_->Setup(event_loop_->monotonic_now() + polling_period_,
- polling_period_);
+ timer_handler_->Schedule(event_loop_->monotonic_now() + polling_period_,
+ polling_period_);
}
std::unique_ptr<LogNamer> Logger::RestartLogging(
diff --git a/aos/events/logging/logger_test.cc b/aos/events/logging/logger_test.cc
index 8b1b7fa..1c48d2c 100644
--- a/aos/events/logging/logger_test.cc
+++ b/aos/events/logging/logger_test.cc
@@ -434,8 +434,8 @@
// 100 ms / 0.05 ms -> 2000 messages. Should be enough to crash it.
ping_spammer_event_loop->OnRun([&ping_spammer_event_loop, timer_handler]() {
- timer_handler->Setup(ping_spammer_event_loop->monotonic_now(),
- chrono::microseconds(50));
+ timer_handler->Schedule(ping_spammer_event_loop->monotonic_now(),
+ chrono::microseconds(50));
});
Logger logger(logger_event_loop.get());
@@ -496,7 +496,7 @@
ping_spammer_event_loop->OnRun(
[&ping_spammer_event_loop, kSendPeriod, timer_handler]() {
- timer_handler->Setup(
+ timer_handler->Schedule(
ping_spammer_event_loop->monotonic_now() + kSendPeriod / 2,
kSendPeriod);
});
diff --git a/aos/events/logging/realtime_replay_test.cc b/aos/events/logging/realtime_replay_test.cc
index a04da49..8c7751e 100644
--- a/aos/events/logging/realtime_replay_test.cc
+++ b/aos/events/logging/realtime_replay_test.cc
@@ -110,7 +110,7 @@
shm_event_loop.MakeFetcher<examples::Ping>("/test");
shm_event_loop.AddTimer([]() { LOG(INFO) << "Hello, World!"; })
- ->Setup(shm_event_loop.monotonic_now(), std::chrono::seconds(1));
+ ->Schedule(shm_event_loop.monotonic_now(), std::chrono::seconds(1));
shm_event_loop.Run();
reader.Deregister();
@@ -149,7 +149,7 @@
shm_event_loop.MakeFetcher<examples::Pong>("/test");
shm_event_loop.AddTimer([]() { LOG(INFO) << "Hello, World!"; })
- ->Setup(shm_event_loop.monotonic_now(), std::chrono::seconds(1));
+ ->Schedule(shm_event_loop.monotonic_now(), std::chrono::seconds(1));
// End timer should not be called in this case, it should automatically quit
// the event loop and check for number of fetches messages
@@ -165,8 +165,8 @@
});
shm_event_loop.OnRun([&shm_event_loop, end_timer, run_seconds]() {
LOG(INFO) << "Quitting in: " << run_seconds;
- end_timer->Setup(shm_event_loop.monotonic_now() +
- std::chrono::seconds(run_seconds));
+ end_timer->Schedule(shm_event_loop.monotonic_now() +
+ std::chrono::seconds(run_seconds));
});
shm_event_loop.Run();
@@ -213,7 +213,7 @@
shm_event_loop.MakeFetcher<examples::Ping>("/test");
shm_event_loop.AddTimer([]() { LOG(INFO) << "Hello, World!"; })
- ->Setup(shm_event_loop.monotonic_now(), std::chrono::seconds(1));
+ ->Schedule(shm_event_loop.monotonic_now(), std::chrono::seconds(1));
shm_event_loop.Run();
reader.Deregister();
@@ -262,7 +262,7 @@
shm_event_loop.MakeFetcher<examples::Ping>("/test");
shm_event_loop.AddTimer([]() { LOG(INFO) << "Hello, World!"; })
- ->Setup(shm_event_loop.monotonic_now(), std::chrono::seconds(1));
+ ->Schedule(shm_event_loop.monotonic_now(), std::chrono::seconds(1));
shm_event_loop.Run();
reader.Deregister();
@@ -321,8 +321,8 @@
size_t run_seconds = 3;
shm_event_loop.OnRun([&shm_event_loop, end_timer, run_seconds]() {
LOG(INFO) << "Quitting in: " << run_seconds;
- end_timer->Setup(shm_event_loop.monotonic_now() +
- std::chrono::seconds(run_seconds));
+ end_timer->Schedule(shm_event_loop.monotonic_now() +
+ std::chrono::seconds(run_seconds));
});
shm_event_loop.Run();