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/network/log_web_proxy_main.cc b/aos/network/log_web_proxy_main.cc
index 7833808..f93c5a2 100644
--- a/aos/network/log_web_proxy_main.cc
+++ b/aos/network/log_web_proxy_main.cc
@@ -57,7 +57,7 @@
if (FLAGS_monotonic_start_time > 0) {
event_loop->AddTimer([&reader]() { reader.event_loop_factory()->Exit(); })
- ->Setup(aos::monotonic_clock::time_point(
+ ->Schedule(aos::monotonic_clock::time_point(
std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::duration<double>(FLAGS_monotonic_start_time))));
@@ -72,7 +72,7 @@
if (FLAGS_monotonic_end_time > 0) {
event_loop->AddTimer([&web_proxy]() { web_proxy.StopRecording(); })
- ->Setup(aos::monotonic_clock::time_point(
+ ->Schedule(aos::monotonic_clock::time_point(
std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::duration<double>(FLAGS_monotonic_end_time))));
}
diff --git a/aos/network/message_bridge_client_lib.cc b/aos/network/message_bridge_client_lib.cc
index 38512c4..a340553 100644
--- a/aos/network/message_bridge_client_lib.cc
+++ b/aos/network/message_bridge_client_lib.cc
@@ -127,7 +127,7 @@
connect_timer_->set_name(std::string("connect_") +
remote_node_->name()->str());
event_loop_->OnRun(
- [this]() { connect_timer_->Setup(event_loop_->monotonic_now()); });
+ [this]() { connect_timer_->Schedule(event_loop_->monotonic_now()); });
size_t max_write_size =
std::max(kHeaderSizeOverhead(), connect_message_.span().size());
@@ -248,7 +248,7 @@
void SctpClientConnection::NodeDisconnected() {
client_.SetAssociationId(0);
- connect_timer_->Setup(
+ connect_timer_->Schedule(
event_loop_->monotonic_now() + chrono::milliseconds(100),
chrono::milliseconds(100));
client_status_->Disconnect(client_index_);
diff --git a/aos/network/message_bridge_client_lib.h b/aos/network/message_bridge_client_lib.h
index 6e108df..a5a69e3 100644
--- a/aos/network/message_bridge_client_lib.h
+++ b/aos/network/message_bridge_client_lib.h
@@ -59,8 +59,8 @@
// gets dropped, the server might be waiting for this, so if we don't hear
// from the server for a while we'll try sending it again.
void ScheduleConnectTimeout() {
- connect_timer_->Setup(event_loop_->context().monotonic_event_time +
- kReconnectTimeout);
+ connect_timer_->Schedule(event_loop_->context().monotonic_event_time +
+ kReconnectTimeout);
}
// Event loop to register the server on.
diff --git a/aos/network/message_bridge_client_status.cc b/aos/network/message_bridge_client_status.cc
index f3511a0..2ba2ae0 100644
--- a/aos/network/message_bridge_client_status.cc
+++ b/aos/network/message_bridge_client_status.cc
@@ -67,8 +67,8 @@
statistics_timer_->set_name("statistics");
event_loop_->OnRun([this]() {
if (send_) {
- statistics_timer_->Setup(event_loop_->monotonic_now() + kStatisticsPeriod,
- kStatisticsPeriod);
+ statistics_timer_->Schedule(
+ event_loop_->monotonic_now() + kStatisticsPeriod, kStatisticsPeriod);
}
});
}
@@ -230,8 +230,8 @@
void MessageBridgeClientStatus::EnableStatistics() {
CHECK(sender_.valid());
send_ = true;
- statistics_timer_->Setup(event_loop_->monotonic_now() + kStatisticsPeriod,
- kStatisticsPeriod);
+ statistics_timer_->Schedule(event_loop_->monotonic_now() + kStatisticsPeriod,
+ kStatisticsPeriod);
}
} // namespace message_bridge
diff --git a/aos/network/message_bridge_server_status.cc b/aos/network/message_bridge_server_status.cc
index df87134..96917f1 100644
--- a/aos/network/message_bridge_server_status.cc
+++ b/aos/network/message_bridge_server_status.cc
@@ -131,8 +131,8 @@
event_loop_->node()->name()->string_view(), "_server_statistics"));
event_loop_->OnRun([this]() {
if (send_) {
- statistics_timer_->Setup(event_loop_->monotonic_now() + kPingPeriod,
- kPingPeriod);
+ statistics_timer_->Schedule(event_loop_->monotonic_now() + kPingPeriod,
+ kPingPeriod);
}
});
}
@@ -433,8 +433,8 @@
send_ = true;
CHECK(sender_.valid());
CHECK(timestamp_sender_.valid());
- statistics_timer_->Setup(event_loop_->monotonic_now() + kPingPeriod,
- kPingPeriod);
+ statistics_timer_->Schedule(event_loop_->monotonic_now() + kPingPeriod,
+ kPingPeriod);
}
} // namespace message_bridge
diff --git a/aos/network/message_bridge_test.cc b/aos/network/message_bridge_test.cc
index 153f1e5..07a56f0 100644
--- a/aos/network/message_bridge_test.cc
+++ b/aos/network/message_bridge_test.cc
@@ -89,12 +89,12 @@
}
void RunPi1Server(chrono::nanoseconds duration) {
- // Setup a shutdown callback.
+ // Set up a shutdown callback.
aos::TimerHandler *const quit = pi1_server_event_loop->AddTimer(
[this]() { pi1_server_event_loop->Exit(); });
pi1_server_event_loop->OnRun([this, quit, duration]() {
// Stop between timestamps, not exactly on them.
- quit->Setup(pi1_server_event_loop->monotonic_now() + duration);
+ quit->Schedule(pi1_server_event_loop->monotonic_now() + duration);
});
pi1_server_event_loop->Run();
@@ -193,12 +193,12 @@
}
void RunPi2Server(chrono::nanoseconds duration) {
- // Setup a shutdown callback.
+ // Set up a shutdown callback.
aos::TimerHandler *const quit = pi2_server_event_loop->AddTimer(
[this]() { pi2_server_event_loop->Exit(); });
pi2_server_event_loop->OnRun([this, quit, duration]() {
// Stop between timestamps, not exactly on them.
- quit->Setup(pi2_server_event_loop->monotonic_now() + duration);
+ quit->Schedule(pi2_server_event_loop->monotonic_now() + duration);
});
pi2_server_event_loop->Run();
@@ -237,7 +237,7 @@
[this]() { pi2_client_event_loop->Exit(); });
pi2_client_event_loop->OnRun([this, quit, duration]() {
// Stop between timestamps, not exactly on them.
- quit->Setup(pi2_client_event_loop->monotonic_now() + duration);
+ quit->Schedule(pi2_client_event_loop->monotonic_now() + duration);
});
// And go!
@@ -594,7 +594,8 @@
[&ping_event_loop]() { ping_event_loop.Exit(); });
ping_event_loop.OnRun([quit, &ping_event_loop]() {
// Stop between timestamps, not exactly on them.
- quit->Setup(ping_event_loop.monotonic_now() + chrono::milliseconds(5050));
+ quit->Schedule(ping_event_loop.monotonic_now() +
+ chrono::milliseconds(5050));
});
// Find the channel index for both the /pi1/aos Timestamp channel and Ping
diff --git a/aos/network/multinode_timestamp_filter_test.cc b/aos/network/multinode_timestamp_filter_test.cc
index 1446e77..9b37806 100644
--- a/aos/network/multinode_timestamp_filter_test.cc
+++ b/aos/network/multinode_timestamp_filter_test.cc
@@ -431,7 +431,7 @@
const BootTimestamp e{0, monotonic_clock::epoch()};
const BootTimestamp ta = e + chrono::milliseconds(500);
- // Setup a time problem with an interesting shape that isn't simple and
+ // Set up a time problem with an interesting shape that isn't simple and
// parallel.
NoncausalTimestampFilter a(node_a, node_b);
a.Sample(e, {0, chrono::milliseconds(1000)});
diff --git a/aos/network/web_proxy.cc b/aos/network/web_proxy.cc
index d7ab418..7f52611 100644
--- a/aos/network/web_proxy.cc
+++ b/aos/network/web_proxy.cc
@@ -65,7 +65,8 @@
});
event_loop_->OnRun([this, timer]() {
- timer->Setup(event_loop_->monotonic_now(), std::chrono::milliseconds(100));
+ timer->Schedule(event_loop_->monotonic_now(),
+ std::chrono::milliseconds(100));
});
}
@@ -189,7 +190,8 @@
});
event_loop->OnRun([timer, event_loop]() {
- timer->Setup(event_loop->monotonic_now(), std::chrono::milliseconds(10));
+ timer->Schedule(event_loop->monotonic_now(),
+ std::chrono::milliseconds(10));
});
}
}
@@ -237,7 +239,7 @@
fbb.Finish(message_offset);
// Now, the flatbuffer is built from the back to the front. So any
- // extra memory will be at the front. Setup the end and start
+ // extra memory will be at the front. Set up the end and start
// pointers on the mbuf.
mbuf_set_end(mbuffer, packet_size);
mbuf_set_pos(mbuffer, packet_size - fbb.GetSize());
diff --git a/aos/network/www/demo_plot.ts b/aos/network/www/demo_plot.ts
index b586411..19bb4a5 100644
--- a/aos/network/www/demo_plot.ts
+++ b/aos/network/www/demo_plot.ts
@@ -33,7 +33,7 @@
const aosPlotter = new AosPlotter(conn);
{
- // Setup a plot that shows some arbitrary PDP current values.
+ // Set up a plot that shows some arbitrary PDP current values.
const pdpValues =
aosPlotter.addMessageSource('/aos', 'frc971.PDPValues');
const timingPlot = aosPlotter.addPlot(parentDiv);
@@ -55,7 +55,7 @@
{
const timingReport =
aosPlotter.addMessageSource('/aos', 'aos.timing.Report');
- // Setup a plot that just shows some arbitrary timing data.
+ // Set up a plot that just shows some arbitrary timing data.
const timingPlot = aosPlotter.addPlot(parentDiv);
timingPlot.plot.getAxisLabels().setTitle('Timing Report Wakeups');
timingPlot.plot.getAxisLabels().setYLabel('PID');