summaryrefslogtreecommitdiffstats
path: root/monitor/trust_group.hpp
diff options
context:
space:
mode:
authorMatthew Barth <msbarth@us.ibm.com>2018-02-16 16:11:13 -0600
committerMatthew Barth <msbarth@us.ibm.com>2018-03-01 09:09:06 -0600
commit32affb9879b18226b3a026072ce1753f03b7ca58 (patch)
tree904d3601317005055d5b7c9a7e08ed6896d9733f /monitor/trust_group.hpp
parent069e4405a6926cdacc33c0826075356da2cd9dbd (diff)
downloadphosphor-fan-presence-32affb9879b18226b3a026072ce1753f03b7ca58.tar.gz
phosphor-fan-presence-32affb9879b18226b3a026072ce1753f03b7ca58.zip
optimize: Tach sensors as shared pointers
The fan and trust group objects should utilize shared pointers to the tach sensor objects. This allows optimizing the storage of additional attributes associated with the tach sensors. e.g. An attribute to declare which sensors should be included in the trust determination. Tested: Current trust group associations & reactions are unchanged Change-Id: I249cc7debf467e8275fae7fa157ce97078b40802 Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
Diffstat (limited to 'monitor/trust_group.hpp')
-rw-r--r--monitor/trust_group.hpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/monitor/trust_group.hpp b/monitor/trust_group.hpp
index e0db5c9..ff60508 100644
--- a/monitor/trust_group.hpp
+++ b/monitor/trust_group.hpp
@@ -57,7 +57,7 @@ class Group
*
* @param[in] sensor - the TachSensor to register
*/
- void registerSensor(std::unique_ptr<monitor::TachSensor>& sensor)
+ void registerSensor(std::shared_ptr<monitor::TachSensor>& sensor)
{
auto found = std::find_if(
_names.begin(),
@@ -89,7 +89,7 @@ class Group
_sensors.end(),
[&sensor](const auto& s)
{
- return sensor.name() == s.get()->name();
+ return sensor.name() == s->name();
}) != _sensors.end());
}
@@ -107,7 +107,7 @@ class Group
_sensors.end(),
[](const auto& s)
{
- s.get()->stopTimer();
+ s->stopTimer();
});
}
@@ -126,11 +126,11 @@ class Group
{
//If a sensor isn't functional, then its timer
//already expired so don't bother starting it again
- if (s.get()->functional() &&
- static_cast<uint64_t>(s.get()->getInput()) !=
- s.get()->getTarget())
+ if (s->functional() &&
+ static_cast<uint64_t>(s->getInput()) !=
+ s->getTarget())
{
- s.get()->startTimer();
+ s->startTimer();
}
});
}
@@ -194,8 +194,7 @@ class Group
*
* Added by registerSensor().
*/
- std::vector<std::reference_wrapper<
- std::unique_ptr<monitor::TachSensor>>> _sensors;
+ std::vector<std::shared_ptr<monitor::TachSensor>> _sensors;
private:
OpenPOWER on IntegriCloud