timer: Remove in favor of sdeventplus/timer
Lets use the new standard event loop timer utility that comes with
sdeventplus instead of the one copied from other projects.
Change-Id: Ie7c8f462f2c0e2e05ce14da58b30a1f91acbf75d
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/mainloop.cpp b/mainloop.cpp
index 81faa9b..5cae0d3 100644
--- a/mainloop.cpp
+++ b/mainloop.cpp
@@ -252,7 +252,8 @@
_bus(std::move(bus)),
_manager(_bus, root), _pathParam(param), _hwmonRoot(), _instance(),
_devPath(devPath), _prefix(prefix), _root(root), state(), ioAccess(path),
- event(sdeventplus::Event::get_default())
+ event(sdeventplus::Event::get_default()),
+ timer(event, std::bind(&MainLoop::read, this))
{
// Strip off any trailing slashes.
std::string p = path;
@@ -276,7 +277,6 @@
void MainLoop::shutdown() noexcept
{
- timer->state(phosphor::hwmon::timer::OFF);
event.exit(0);
}
@@ -287,9 +287,7 @@
std::function<void()> callback(std::bind(&MainLoop::read, this));
try
{
- timer = std::make_unique<phosphor::hwmon::Timer>(
- event.get(), callback, std::chrono::microseconds(_interval),
- phosphor::hwmon::timer::ON);
+ timer.restart(std::chrono::microseconds(_interval));
// TODO: Issue#6 - Optionally look at polling interval sysfs entry.