Move to steady_timer
deadline_timer and steady_timer have one important difference, the
former runs off CLOCK_REALTIME, and the later runs off CLOCK_MONOTONIC.
For a long time we've relied on deadline_timer incorrectly, given that
dbus-sensors does not care in the least about the calendar time, and
only cares about the difference between sensor scans.
Fortunately, this likely has no effect on the behavior of the sensors
most of the time, and in general, in a time change, the clock generally
moves forward, so all timers would immediately expire, scan all sensors,
and move on. phosphor-pid-control is intentionally designed to handle
this case, so it's quite likely that a user would never notice it, and
even if they did, would have to be looking at a debug console the moment
it happened.
The other effect is that in most cases, sensors call clock_gettime more
than they probably need to, which might slow down the performance.
This commit moves all usages of sensor timing to steady_timer, which
should give us more consistent results, and (in theory at least) be
faster. Because of stdlib compliance things, this also has the effect
of us dropping our dependence on boost::posix_time, and move to
std::chrono::duration objects, per the coding standard.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I69f948fb3f0fc0dfd7fd196d26ba46742a3e15a7
diff --git a/src/PSUSensor.cpp b/src/PSUSensor.cpp
index c5ed373..6e2934f 100644
--- a/src/PSUSensor.cpp
+++ b/src/PSUSensor.cpp
@@ -19,7 +19,6 @@
#include <PSUSensor.hpp>
#include <boost/asio/random_access_file.hpp>
#include <boost/asio/read_until.hpp>
-#include <boost/date_time/posix_time/posix_time.hpp>
#include <sdbusplus/asio/connection.hpp>
#include <sdbusplus/asio/object_server.hpp>
@@ -146,7 +145,7 @@
void PSUSensor::restartRead(void)
{
std::weak_ptr<PSUSensor> weakRef = weak_from_this();
- waitTimer.expires_from_now(boost::posix_time::milliseconds(sensorPollMs));
+ waitTimer.expires_from_now(std::chrono::milliseconds(sensorPollMs));
waitTimer.async_wait([weakRef](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
{