summaryrefslogtreecommitdiffstats
path: root/monitor
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2017-05-11 10:07:55 -0500
committerPatrick Williams <patrick@stwcx.xyz>2017-05-11 19:58:23 +0000
commite824f985e7e32923d9f76e3ad5baf4909880739f (patch)
tree8a89c8fc65f2611101d04ae9c550d4beb707d69d /monitor
parent14321846e57f483f472590b1c5fe35891511312f (diff)
downloadphosphor-fan-presence-e824f985e7e32923d9f76e3ad5baf4909880739f.tar.gz
phosphor-fan-presence-e824f985e7e32923d9f76e3ad5baf4909880739f.zip
Use unique_ptr for sd_event object wrapper
Convert the sd_event object wrapper from a shared_ptr to a unique_ptr. Requires a new header file. Change-Id: I868a9e88ed93878c2e0bb12e58f8d3a604510da0 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Diffstat (limited to 'monitor')
-rw-r--r--monitor/fan.cpp2
-rw-r--r--monitor/fan.hpp3
-rw-r--r--monitor/main.cpp12
-rw-r--r--monitor/tach_sensor.cpp2
-rw-r--r--monitor/tach_sensor.hpp3
5 files changed, 10 insertions, 12 deletions
diff --git a/monitor/fan.cpp b/monitor/fan.cpp
index 639d88e..17f5812 100644
--- a/monitor/fan.cpp
+++ b/monitor/fan.cpp
@@ -38,7 +38,7 @@ constexpr auto OPERATIONAL_STATUS_INTF =
Fan::Fan(sdbusplus::bus::bus& bus,
- std::shared_ptr<sd_event>& events,
+ phosphor::fan::event::EventPtr& events,
const FanDefinition& def) :
_bus(bus),
_name(std::get<fanNameField>(def)),
diff --git a/monitor/fan.hpp b/monitor/fan.hpp
index 910b4eb..8e7f86f 100644
--- a/monitor/fan.hpp
+++ b/monitor/fan.hpp
@@ -3,6 +3,7 @@
#include <sdbusplus/bus.hpp>
#include <tuple>
#include <vector>
+#include "event.hpp"
#include "tach_sensor.hpp"
#include "types.hpp"
@@ -72,7 +73,7 @@ class Fan
* @param def - the fan definition structure
*/
Fan(sdbusplus::bus::bus& bus,
- std::shared_ptr<sd_event>& events,
+ phosphor::fan::event::EventPtr& events,
const FanDefinition& def);
/**
diff --git a/monitor/main.cpp b/monitor/main.cpp
index 6d51fbb..c10efb9 100644
--- a/monitor/main.cpp
+++ b/monitor/main.cpp
@@ -15,6 +15,7 @@
*/
#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
+#include "event.hpp"
#include "fan.hpp"
#include "fan_defs.hpp"
@@ -22,16 +23,11 @@ using namespace phosphor::fan::monitor;
using namespace phosphor::logging;
-void EventDeleter(sd_event* event)
-{
- sd_event_unref(event);
-}
-
int main()
{
auto bus = sdbusplus::bus::new_default();
sd_event* events = nullptr;
- std::vector<std::unique_ptr<Fan>> fans;
+ std::vector<Fan> fans;
auto r = sd_event_default(&events);
if (r < 0)
@@ -41,7 +37,7 @@ int main()
return -1;
}
- std::shared_ptr<sd_event> eventPtr{events, EventDeleter};
+ phosphor::fan::event::EventPtr eventPtr{events};
//Attach the event object to the bus object so we can
//handle both sd_events (for the timers) and dbus signals.
@@ -49,7 +45,7 @@ int main()
for (const auto& fanDef : fanDefinitions)
{
- fans.emplace_back(std::make_unique<Fan>(bus, eventPtr, fanDef));
+ fans.emplace_back(bus, eventPtr, fanDef);
}
r = sd_event_loop(eventPtr.get());
diff --git a/monitor/tach_sensor.cpp b/monitor/tach_sensor.cpp
index 806eed7..80eb974 100644
--- a/monitor/tach_sensor.cpp
+++ b/monitor/tach_sensor.cpp
@@ -85,7 +85,7 @@ TachSensor::TachSensor(sdbusplus::bus::bus& bus,
const std::string& id,
bool hasTarget,
size_t timeout,
- std::shared_ptr<sd_event>& events) :
+ phosphor::fan::event::EventPtr& events) :
_bus(bus),
_fan(fan),
_name(FAN_SENSOR_PATH + id),
diff --git a/monitor/tach_sensor.hpp b/monitor/tach_sensor.hpp
index 7a65b64..84e02fe 100644
--- a/monitor/tach_sensor.hpp
+++ b/monitor/tach_sensor.hpp
@@ -3,6 +3,7 @@
#include <chrono>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server.hpp>
+#include "event.hpp"
#include "timer.hpp"
namespace phosphor
@@ -54,7 +55,7 @@ class TachSensor
const std::string& id,
bool hasTarget,
size_t timeout,
- std::shared_ptr<sd_event>& events);
+ phosphor::fan::event::EventPtr& events);
/**
* @brief Returns the target speed value
OpenPOWER on IntegriCloud