Increase poll time on failure
Polling on failure causes increased CPU usage,
slow it down. Also always use update value instead
of setting value directly.
Tested-by: Turned off system and noticed lower cpu
usage.
Change-Id: I922ff016ba9dde9da77aa6dc95951d2f3d3f8259
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/src/CPUSensor.cpp b/src/CPUSensor.cpp
index 98201b1..236dd81 100644
--- a/src/CPUSensor.cpp
+++ b/src/CPUSensor.cpp
@@ -89,6 +89,7 @@
{
return; // we're being destroyed
}
+ size_t pollTime = CPUSensor::sensorPollMs;
std::istream responseStream(&readBuf);
if (!err)
{
@@ -112,6 +113,7 @@
}
else
{
+ pollTime = sensorFailedPollTimeMs;
errCount++;
}
@@ -129,8 +131,7 @@
else
{
errCount = 0; // check power again in 10 cycles
- sensorInterface->set_property(
- "Value", std::numeric_limits<double>::quiet_NaN());
+ updateValue(std::numeric_limits<double>::quiet_NaN());
}
}
@@ -142,8 +143,7 @@
return; // we're no longer valid
}
inputDev.assign(fd);
- waitTimer.expires_from_now(
- boost::posix_time::milliseconds(CPUSensor::sensorPollMs));
+ waitTimer.expires_from_now(boost::posix_time::milliseconds(pollTime));
waitTimer.async_wait([&](const boost::system::error_code &ec) {
if (ec == boost::asio::error::operation_aborted)
{