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/include/ADCSensor.hpp b/include/ADCSensor.hpp
index 79c220a..5c4b8ed 100644
--- a/include/ADCSensor.hpp
+++ b/include/ADCSensor.hpp
@@ -79,7 +79,7 @@
private:
sdbusplus::asio::object_server& objServer;
boost::asio::posix::stream_descriptor inputDev;
- boost::asio::deadline_timer waitTimer;
+ boost::asio::steady_timer waitTimer;
std::shared_ptr<boost::asio::streambuf> readBuf;
std::string path;
double scaleFactor;
diff --git a/include/ChassisIntrusionSensor.hpp b/include/ChassisIntrusionSensor.hpp
index 56affca..8954033 100644
--- a/include/ChassisIntrusionSensor.hpp
+++ b/include/ChassisIntrusionSensor.hpp
@@ -1,7 +1,7 @@
#pragma once
-#include <boost/asio/deadline_timer.hpp>
#include <boost/asio/io_service.hpp>
+#include <boost/asio/steady_timer.hpp>
#include <gpiod.hpp>
#include <sdbusplus/asio/object_server.hpp>
@@ -39,7 +39,7 @@
// valid if it is PCH register via i2c
int mBusId{-1};
int mSlaveAddr{-1};
- boost::asio::deadline_timer mPollTimer;
+ boost::asio::steady_timer mPollTimer;
// valid if it is via GPIO
bool mGpioInverted{false};
diff --git a/include/HwmonTempSensor.hpp b/include/HwmonTempSensor.hpp
index 640875b..af275ec 100644
--- a/include/HwmonTempSensor.hpp
+++ b/include/HwmonTempSensor.hpp
@@ -40,7 +40,7 @@
std::array<char, 128> readBuf{};
sdbusplus::asio::object_server& objServer;
boost::asio::random_access_file inputDev;
- boost::asio::deadline_timer waitTimer;
+ boost::asio::steady_timer waitTimer;
std::string path;
double offsetValue;
double scaleValue;
diff --git a/include/IntelCPUSensor.hpp b/include/IntelCPUSensor.hpp
index 844c861..5f9124e 100644
--- a/include/IntelCPUSensor.hpp
+++ b/include/IntelCPUSensor.hpp
@@ -39,7 +39,7 @@
sdbusplus::asio::object_server& objServer;
boost::asio::streambuf readBuf;
boost::asio::posix::stream_descriptor inputDev;
- boost::asio::deadline_timer waitTimer;
+ boost::asio::steady_timer waitTimer;
std::string nameTcontrol;
std::string path;
double privTcontrol;
diff --git a/include/IpmbSensor.hpp b/include/IpmbSensor.hpp
index 93c06fb..f142a5a 100644
--- a/include/IpmbSensor.hpp
+++ b/include/IpmbSensor.hpp
@@ -1,5 +1,5 @@
#pragma once
-#include <boost/asio/deadline_timer.hpp>
+#include <boost/asio/steady_timer.hpp>
#include <boost/container/flat_map.hpp>
#include <sensor.hpp>
@@ -116,5 +116,5 @@
private:
sdbusplus::asio::object_server& objectServer;
- boost::asio::deadline_timer waitTimer;
+ boost::asio::steady_timer waitTimer;
};
diff --git a/include/MCUTempSensor.hpp b/include/MCUTempSensor.hpp
index e0474f1..c4c2406 100644
--- a/include/MCUTempSensor.hpp
+++ b/include/MCUTempSensor.hpp
@@ -1,5 +1,5 @@
#pragma once
-#include <boost/asio/deadline_timer.hpp>
+#include <boost/asio/steady_timer.hpp>
#include <boost/container/flat_map.hpp>
#include <sensor.hpp>
@@ -30,5 +30,5 @@
private:
int getMCURegsInfoWord(uint8_t regs, int16_t* pu16data) const;
sdbusplus::asio::object_server& objectServer;
- boost::asio::deadline_timer waitTimer;
+ boost::asio::steady_timer waitTimer;
};
diff --git a/include/NVMeContext.hpp b/include/NVMeContext.hpp
index 230ca74..5be03e0 100644
--- a/include/NVMeContext.hpp
+++ b/include/NVMeContext.hpp
@@ -2,8 +2,8 @@
#include "NVMeSensor.hpp"
-#include <boost/asio/deadline_timer.hpp>
#include <boost/asio/io_service.hpp>
+#include <boost/asio/steady_timer.hpp>
#include <memory>
#include <stdexcept>
@@ -98,7 +98,7 @@
size_t len) = 0;
protected:
- boost::asio::deadline_timer scanTimer;
+ boost::asio::steady_timer scanTimer;
int rootBus; // Root bus for this drive
std::list<std::shared_ptr<NVMeSensor>> sensors;
std::list<std::shared_ptr<NVMeSensor>>::iterator pollCursor;
diff --git a/include/PSUEvent.hpp b/include/PSUEvent.hpp
index 824019c..25a7ebc 100644
--- a/include/PSUEvent.hpp
+++ b/include/PSUEvent.hpp
@@ -17,9 +17,9 @@
#pragma once
#include <Utils.hpp>
-#include <boost/asio/deadline_timer.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/asio/random_access_file.hpp>
+#include <boost/asio/steady_timer.hpp>
#include <boost/container/flat_map.hpp>
#include <sdbusplus/asio/object_server.hpp>
@@ -56,7 +56,7 @@
std::string eventName;
PowerState readState;
- boost::asio::deadline_timer waitTimer;
+ boost::asio::steady_timer waitTimer;
std::shared_ptr<std::array<char, 128>> buffer;
void restartRead();
void handleResponse(const boost::system::error_code& err,
diff --git a/include/PSUSensor.hpp b/include/PSUSensor.hpp
index 6466179..63699ea 100644
--- a/include/PSUSensor.hpp
+++ b/include/PSUSensor.hpp
@@ -33,7 +33,7 @@
std::shared_ptr<std::array<char, 128>> buffer;
sdbusplus::asio::object_server& objServer;
boost::asio::random_access_file inputDev;
- boost::asio::deadline_timer waitTimer;
+ boost::asio::steady_timer waitTimer;
std::string path;
unsigned int sensorFactor;
double sensorOffset;
diff --git a/include/TachSensor.hpp b/include/TachSensor.hpp
index a9da29f..c360395 100644
--- a/include/TachSensor.hpp
+++ b/include/TachSensor.hpp
@@ -87,7 +87,7 @@
std::shared_ptr<sdbusplus::asio::dbus_interface> itemIface;
std::shared_ptr<sdbusplus::asio::dbus_interface> itemAssoc;
boost::asio::random_access_file inputDev;
- boost::asio::deadline_timer waitTimer;
+ boost::asio::steady_timer waitTimer;
std::string path;
std::optional<std::string> led;
bool ledState = false;
diff --git a/include/Thresholds.hpp b/include/Thresholds.hpp
index ae1f528..0b17c62 100644
--- a/include/Thresholds.hpp
+++ b/include/Thresholds.hpp
@@ -1,7 +1,7 @@
#pragma once
#include <Utils.hpp>
-#include <boost/asio/deadline_timer.hpp>
#include <boost/asio/io_service.hpp>
+#include <boost/asio/steady_timer.hpp>
#include <nlohmann/json.hpp>
#include <list>
@@ -62,7 +62,7 @@
bool assert;
};
-using TimerPair = std::pair<struct TimerUsed, boost::asio::deadline_timer>;
+using TimerPair = std::pair<struct TimerUsed, boost::asio::steady_timer>;
struct ThresholdTimer
{
diff --git a/src/ADCSensor.cpp b/src/ADCSensor.cpp
index eacce22..fe2c8a7 100644
--- a/src/ADCSensor.cpp
+++ b/src/ADCSensor.cpp
@@ -18,7 +18,6 @@
#include <ADCSensor.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>
@@ -109,7 +108,7 @@
// value. Guarantee that the HW signal can be stable, the HW signal
// could be instability.
waitTimer.expires_from_now(
- boost::posix_time::milliseconds(bridgeGpio->setupTimeMs));
+ std::chrono::milliseconds(bridgeGpio->setupTimeMs));
waitTimer.async_wait(
[weakRef, buffer](const boost::system::error_code& ec) {
std::shared_ptr<ADCSensor> self = weakRef.lock();
@@ -198,7 +197,7 @@
return; // we're no longer valid
}
inputDev.assign(fd);
- 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) {
std::shared_ptr<ADCSensor> self = weakRef.lock();
if (ec == boost::asio::error::operation_aborted)
diff --git a/src/ADCSensorMain.cpp b/src/ADCSensorMain.cpp
index a2f6514..05d586f 100644
--- a/src/ADCSensorMain.cpp
+++ b/src/ADCSensorMain.cpp
@@ -320,7 +320,7 @@
UpdateType::init);
});
- boost::asio::deadline_timer filterTimer(io);
+ boost::asio::steady_timer filterTimer(io);
std::function<void(sdbusplus::message_t&)> eventHandler =
[&](sdbusplus::message_t& message) {
if (message.is_method_error())
@@ -330,7 +330,7 @@
}
sensorsChanged->insert(message.get_path());
// this implicitly cancels the timer
- filterTimer.expires_from_now(boost::posix_time::seconds(1));
+ filterTimer.expires_from_now(std::chrono::seconds(1));
filterTimer.async_wait([&](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
@@ -378,7 +378,7 @@
}
// this implicitly cancels the timer
- filterTimer.expires_from_now(boost::posix_time::seconds(1));
+ filterTimer.expires_from_now(std::chrono::seconds(1));
filterTimer.async_wait([&](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
diff --git a/src/ChassisIntrusionSensor.cpp b/src/ChassisIntrusionSensor.cpp
index 6c40717..2bb04ce 100644
--- a/src/ChassisIntrusionSensor.cpp
+++ b/src/ChassisIntrusionSensor.cpp
@@ -146,8 +146,7 @@
void ChassisIntrusionSensor::pollSensorStatusByPch()
{
// setting a new experation implicitly cancels any pending async wait
- mPollTimer.expires_from_now(
- boost::posix_time::seconds(intrusionSensorPollSec));
+ mPollTimer.expires_from_now(std::chrono::seconds(intrusionSensorPollSec));
mPollTimer.async_wait([&](const boost::system::error_code& ec) {
// case of timer expired
diff --git a/src/ExitAirTempSensor.cpp b/src/ExitAirTempSensor.cpp
index 33fd079..eb816e8 100644
--- a/src/ExitAirTempSensor.cpp
+++ b/src/ExitAirTempSensor.cpp
@@ -938,11 +938,11 @@
io.post([&]() { createSensor(objectServer, sensor, systemBus); });
- boost::asio::deadline_timer configTimer(io);
+ boost::asio::steady_timer configTimer(io);
std::function<void(sdbusplus::message_t&)> eventHandler =
[&](sdbusplus::message_t&) {
- configTimer.expires_from_now(boost::posix_time::seconds(1));
+ configTimer.expires_from_now(std::chrono::seconds(1));
// create a timer because normally multiple properties change
configTimer.async_wait([&](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
diff --git a/src/ExternalSensor.cpp b/src/ExternalSensor.cpp
index 3a6c4aa..cbba6e1 100644
--- a/src/ExternalSensor.cpp
+++ b/src/ExternalSensor.cpp
@@ -4,7 +4,6 @@
#include <unistd.h>
-#include <boost/date_time/posix_time/posix_time.hpp>
#include <sdbusplus/asio/connection.hpp>
#include <sdbusplus/asio/object_server.hpp>
diff --git a/src/ExternalSensorMain.cpp b/src/ExternalSensorMain.cpp
index e79098f..23721a8 100644
--- a/src/ExternalSensorMain.cpp
+++ b/src/ExternalSensorMain.cpp
@@ -351,7 +351,7 @@
createSensors(objectServer, sensors, systemBus, nullptr, reaperTimer);
});
- boost::asio::deadline_timer filterTimer(io);
+ boost::asio::steady_timer filterTimer(io);
std::function<void(sdbusplus::message_t&)> eventHandler =
[&objectServer, &sensors, &systemBus, &sensorsChanged, &filterTimer,
&reaperTimer](sdbusplus::message_t& message) mutable {
@@ -370,7 +370,7 @@
}
// this implicitly cancels the timer
- filterTimer.expires_from_now(boost::posix_time::seconds(1));
+ filterTimer.expires_from_now(std::chrono::seconds(1));
filterTimer.async_wait(
[&objectServer, &sensors, &systemBus, &sensorsChanged,
diff --git a/src/FanMain.cpp b/src/FanMain.cpp
index a192380..9d495e0 100644
--- a/src/FanMain.cpp
+++ b/src/FanMain.cpp
@@ -556,7 +556,7 @@
nullptr);
});
- boost::asio::deadline_timer filterTimer(io);
+ boost::asio::steady_timer filterTimer(io);
std::function<void(sdbusplus::message_t&)> eventHandler =
[&](sdbusplus::message_t& message) {
if (message.is_method_error())
@@ -566,7 +566,7 @@
}
sensorsChanged->insert(message.get_path());
// this implicitly cancels the timer
- filterTimer.expires_from_now(boost::posix_time::seconds(1));
+ filterTimer.expires_from_now(std::chrono::seconds(1));
filterTimer.async_wait([&](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
diff --git a/src/HwmonTempMain.cpp b/src/HwmonTempMain.cpp
index 4ee020a..9ebdfcd 100644
--- a/src/HwmonTempMain.cpp
+++ b/src/HwmonTempMain.cpp
@@ -532,7 +532,7 @@
createSensors(io, objectServer, sensors, systemBus, nullptr);
});
- boost::asio::deadline_timer filterTimer(io);
+ boost::asio::steady_timer filterTimer(io);
std::function<void(sdbusplus::message_t&)> eventHandler =
[&](sdbusplus::message_t& message) {
if (message.is_method_error())
@@ -542,7 +542,7 @@
}
sensorsChanged->insert(message.get_path());
// this implicitly cancels the timer
- filterTimer.expires_from_now(boost::posix_time::seconds(1));
+ filterTimer.expires_from_now(std::chrono::seconds(1));
filterTimer.async_wait([&](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
diff --git a/src/HwmonTempSensor.cpp b/src/HwmonTempSensor.cpp
index 3f19ec1..ee096ea 100644
--- a/src/HwmonTempSensor.cpp
+++ b/src/HwmonTempSensor.cpp
@@ -18,7 +18,6 @@
#include <HwmonTempSensor.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>
@@ -116,7 +115,7 @@
void HwmonTempSensor::restartRead()
{
std::weak_ptr<HwmonTempSensor> 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)
{
diff --git a/src/IntelCPUSensor.cpp b/src/IntelCPUSensor.cpp
index 8f04e99..3410574 100644
--- a/src/IntelCPUSensor.cpp
+++ b/src/IntelCPUSensor.cpp
@@ -20,7 +20,6 @@
#include <Utils.hpp>
#include <boost/algorithm/string/replace.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>
@@ -113,7 +112,7 @@
void IntelCPUSensor::restartRead(void)
{
std::weak_ptr<IntelCPUSensor> weakRef = weak_from_this();
- waitTimer.expires_from_now(boost::posix_time::milliseconds(pollTime));
+ waitTimer.expires_from_now(std::chrono::milliseconds(pollTime));
waitTimer.async_wait([weakRef](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
{
diff --git a/src/IntelCPUSensorMain.cpp b/src/IntelCPUSensorMain.cpp
index 485729b..0d7f896 100644
--- a/src/IntelCPUSensorMain.cpp
+++ b/src/IntelCPUSensorMain.cpp
@@ -22,7 +22,6 @@
#include <boost/algorithm/string/replace.hpp>
#include <boost/container/flat_map.hpp>
#include <boost/container/flat_set.hpp>
-#include <boost/date_time/posix_time/posix_time.hpp>
#include <sdbusplus/asio/connection.hpp>
#include <sdbusplus/asio/object_server.hpp>
#include <sdbusplus/bus/match.hpp>
@@ -94,8 +93,8 @@
{IntelCPUSensor::labelTcontrol, "Tthrottle", "Tjmax"})};
void detectCpuAsync(
- boost::asio::deadline_timer& pingTimer,
- boost::asio::deadline_timer& creationTimer, boost::asio::io_service& io,
+ boost::asio::steady_timer& pingTimer,
+ boost::asio::steady_timer& creationTimer, boost::asio::io_service& io,
sdbusplus::asio::object_server& objectServer,
std::shared_ptr<sdbusplus::asio::connection>& dbusConnection,
boost::container::flat_set<CPUConfig>& cpuConfigs,
@@ -447,8 +446,8 @@
std::cout << parameters << " on bus " << busStr << " is exported\n";
}
-void detectCpu(boost::asio::deadline_timer& pingTimer,
- boost::asio::deadline_timer& creationTimer,
+void detectCpu(boost::asio::steady_timer& pingTimer,
+ boost::asio::steady_timer& creationTimer,
boost::asio::io_service& io,
sdbusplus::asio::object_server& objectServer,
std::shared_ptr<sdbusplus::asio::connection>& dbusConnection,
@@ -555,7 +554,7 @@
if (rescanDelaySeconds != 0U)
{
creationTimer.expires_from_now(
- boost::posix_time::seconds(rescanDelaySeconds));
+ std::chrono::seconds(rescanDelaySeconds));
creationTimer.async_wait([&](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
{
@@ -579,14 +578,14 @@
}
void detectCpuAsync(
- boost::asio::deadline_timer& pingTimer,
- boost::asio::deadline_timer& creationTimer, boost::asio::io_service& io,
+ boost::asio::steady_timer& pingTimer,
+ boost::asio::steady_timer& creationTimer, boost::asio::io_service& io,
sdbusplus::asio::object_server& objectServer,
std::shared_ptr<sdbusplus::asio::connection>& dbusConnection,
boost::container::flat_set<CPUConfig>& cpuConfigs,
ManagedObjectType& sensorConfigs)
{
- pingTimer.expires_from_now(boost::posix_time::seconds(1));
+ pingTimer.expires_from_now(std::chrono::seconds(1));
pingTimer.async_wait([&](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
{
@@ -710,12 +709,12 @@
boost::container::flat_set<CPUConfig> cpuConfigs;
sdbusplus::asio::object_server objectServer(systemBus);
- boost::asio::deadline_timer pingTimer(io);
- boost::asio::deadline_timer creationTimer(io);
- boost::asio::deadline_timer filterTimer(io);
+ boost::asio::steady_timer pingTimer(io);
+ boost::asio::steady_timer creationTimer(io);
+ boost::asio::steady_timer filterTimer(io);
ManagedObjectType sensorConfigs;
- filterTimer.expires_from_now(boost::posix_time::seconds(1));
+ filterTimer.expires_from_now(std::chrono::seconds(1));
filterTimer.async_wait([&](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
{
@@ -743,7 +742,7 @@
}
// this implicitly cancels the timer
- filterTimer.expires_from_now(boost::posix_time::seconds(1));
+ filterTimer.expires_from_now(std::chrono::seconds(1));
filterTimer.async_wait([&](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
{
diff --git a/src/IpmbSensor.cpp b/src/IpmbSensor.cpp
index 7c5f965..5dabc25 100644
--- a/src/IpmbSensor.cpp
+++ b/src/IpmbSensor.cpp
@@ -52,7 +52,7 @@
boost::container::flat_map<std::string, std::unique_ptr<IpmbSensor>> sensors;
-std::unique_ptr<boost::asio::deadline_timer> initCmdTimer;
+std::unique_ptr<boost::asio::steady_timer> initCmdTimer;
IpmbSensor::IpmbSensor(std::shared_ptr<sdbusplus::asio::connection>& conn,
boost::asio::io_service& io,
@@ -335,7 +335,7 @@
void IpmbSensor::read(void)
{
- waitTimer.expires_from_now(boost::posix_time::milliseconds(sensorPollMs));
+ waitTimer.expires_from_now(std::chrono::milliseconds(sensorPollMs));
waitTimer.async_wait([this](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
{
@@ -586,7 +586,7 @@
// we seem to send this command too fast sometimes, wait before
// sending
initCmdTimer->expires_from_now(
- boost::posix_time::seconds(reinitWaitSeconds));
+ std::chrono::seconds(reinitWaitSeconds));
initCmdTimer->async_wait([](const boost::system::error_code ec) {
if (ec == boost::asio::error::operation_aborted)
@@ -614,15 +614,15 @@
systemBus->request_name("xyz.openbmc_project.IpmbSensor");
sdbusplus::asio::object_server objectServer(systemBus);
- initCmdTimer = std::make_unique<boost::asio::deadline_timer>(io);
+ initCmdTimer = std::make_unique<boost::asio::steady_timer>(io);
io.post([&]() { createSensors(io, objectServer, sensors, systemBus); });
- boost::asio::deadline_timer configTimer(io);
+ boost::asio::steady_timer configTimer(io);
std::function<void(sdbusplus::message_t&)> eventHandler =
[&](sdbusplus::message_t&) {
- configTimer.expires_from_now(boost::posix_time::seconds(1));
+ configTimer.expires_from_now(std::chrono::seconds(1));
// create a timer because normally multiple properties change
configTimer.async_wait([&](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
diff --git a/src/MCUTempSensor.cpp b/src/MCUTempSensor.cpp
index 47893d2..ba68bed 100644
--- a/src/MCUTempSensor.cpp
+++ b/src/MCUTempSensor.cpp
@@ -151,7 +151,7 @@
{
static constexpr size_t pollTime = 1; // in seconds
- waitTimer.expires_from_now(boost::posix_time::seconds(pollTime));
+ waitTimer.expires_from_now(std::chrono::seconds(pollTime));
waitTimer.async_wait([this](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
{
@@ -263,11 +263,11 @@
io.post([&]() { createSensors(io, objectServer, sensors, systemBus); });
- boost::asio::deadline_timer configTimer(io);
+ boost::asio::steady_timer configTimer(io);
std::function<void(sdbusplus::message_t&)> eventHandler =
[&](sdbusplus::message_t&) {
- configTimer.expires_from_now(boost::posix_time::seconds(1));
+ configTimer.expires_from_now(std::chrono::seconds(1));
// create a timer because normally multiple properties change
configTimer.async_wait([&](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
diff --git a/src/NVMeBasicContext.cpp b/src/NVMeBasicContext.cpp
index 465f177..b4599c7 100644
--- a/src/NVMeBasicContext.cpp
+++ b/src/NVMeBasicContext.cpp
@@ -352,7 +352,7 @@
{
pollCursor = sensors.begin();
- scanTimer.expires_from_now(boost::posix_time::seconds(1));
+ scanTimer.expires_from_now(std::chrono::seconds(1));
scanTimer.async_wait([weakSelf{weak_from_this()}](
const boost::system::error_code errorCode) {
if (errorCode == boost::asio::error::operation_aborted)
diff --git a/src/NVMeSensorMain.cpp b/src/NVMeSensorMain.cpp
index 1398d3c..463ada3 100644
--- a/src/NVMeSensorMain.cpp
+++ b/src/NVMeSensorMain.cpp
@@ -17,7 +17,7 @@
#include <NVMeBasicContext.hpp>
#include <NVMeContext.hpp>
#include <NVMeSensor.hpp>
-#include <boost/asio/deadline_timer.hpp>
+#include <boost/asio/steady_timer.hpp>
#include <optional>
#include <regex>
@@ -235,11 +235,11 @@
io.post([&]() { createSensors(io, objectServer, systemBus); });
- boost::asio::deadline_timer filterTimer(io);
+ boost::asio::steady_timer filterTimer(io);
std::function<void(sdbusplus::message_t&)> eventHandler =
[&filterTimer, &io, &objectServer, &systemBus](sdbusplus::message_t&) {
// this implicitly cancels the timer
- filterTimer.expires_from_now(boost::posix_time::seconds(1));
+ filterTimer.expires_from_now(std::chrono::seconds(1));
filterTimer.async_wait([&](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
diff --git a/src/PSUEvent.cpp b/src/PSUEvent.cpp
index 8c83d06..27bb8b1 100644
--- a/src/PSUEvent.cpp
+++ b/src/PSUEvent.cpp
@@ -218,7 +218,7 @@
void PSUSubEvent::restartRead()
{
std::weak_ptr<PSUSubEvent> weakRef = weak_from_this();
- waitTimer.expires_from_now(boost::posix_time::milliseconds(eventPollMs));
+ waitTimer.expires_from_now(std::chrono::milliseconds(eventPollMs));
waitTimer.async_wait([weakRef](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
{
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)
{
diff --git a/src/PSUSensorMain.cpp b/src/PSUSensorMain.cpp
index 0a197b8..918b9c6 100644
--- a/src/PSUSensorMain.cpp
+++ b/src/PSUSensorMain.cpp
@@ -1050,7 +1050,7 @@
propertyInitialize();
io.post([&]() { createSensors(io, objectServer, systemBus, nullptr); });
- boost::asio::deadline_timer filterTimer(io);
+ boost::asio::steady_timer filterTimer(io);
std::function<void(sdbusplus::message_t&)> eventHandler =
[&](sdbusplus::message_t& message) {
if (message.is_method_error())
@@ -1059,7 +1059,7 @@
return;
}
sensorsChanged->insert(message.get_path());
- filterTimer.expires_from_now(boost::posix_time::seconds(3));
+ filterTimer.expires_from_now(std::chrono::seconds(3));
filterTimer.async_wait([&](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
{
diff --git a/src/TachSensor.cpp b/src/TachSensor.cpp
index dacbec6..35185cd 100644
--- a/src/TachSensor.cpp
+++ b/src/TachSensor.cpp
@@ -19,7 +19,6 @@
#include <TachSensor.hpp>
#include <Utils.hpp>
#include <boost/asio/read_until.hpp>
-#include <boost/date_time/posix_time/posix_time.hpp>
#include <gpiod.hpp>
#include <sdbusplus/asio/connection.hpp>
#include <sdbusplus/asio/object_server.hpp>
@@ -125,7 +124,7 @@
void TachSensor::restartRead(size_t pollTime)
{
std::weak_ptr<TachSensor> weakRef = weak_from_this();
- waitTimer.expires_from_now(boost::posix_time::milliseconds(pollTime));
+ waitTimer.expires_from_now(std::chrono::milliseconds(pollTime));
waitTimer.async_wait([weakRef](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted)
{
diff --git a/src/Thresholds.cpp b/src/Thresholds.cpp
index 610e68e..ee0456d 100644
--- a/src/Thresholds.cpp
+++ b/src/Thresholds.cpp
@@ -339,14 +339,14 @@
}
if (pair == nullptr)
{
- pair = &timers.emplace_back(timerUsed, boost::asio::deadline_timer(io));
+ pair = &timers.emplace_back(timerUsed, boost::asio::steady_timer(io));
}
pair->first.used = true;
pair->first.level = threshold.level;
pair->first.direction = threshold.direction;
pair->first.assert = assert;
- pair->second.expires_from_now(boost::posix_time::seconds(waitTime));
+ pair->second.expires_from_now(std::chrono::seconds(waitTime));
pair->second.async_wait([weakSensor, pair, threshold, assert,
assertValue](boost::system::error_code ec) {
auto sensorPtr = weakSensor.lock();