event: Remove in favor of sdeventplus

Use the new library provided to all openbmc projects instead of rolling
our own managed pointer.

Tested: Compiled

Change-Id: I4993d4340e0e0aa5898e73ef815baa81b0e8a2bc
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/power-sequencer/Makefile.am b/power-sequencer/Makefile.am
index 8806a78..02f6466 100644
--- a/power-sequencer/Makefile.am
+++ b/power-sequencer/Makefile.am
@@ -16,9 +16,11 @@
 	$(top_builddir)/libpower.la \
 	$(PHOSPHOR_LOGGING_LIBS) \
 	${PHOSPHOR_DBUS_INTERFACES_LIBS} \
-	$(SDBUSPLUS_LIBS)
+	$(SDBUSPLUS_LIBS) \
+	$(SDEVENTPLUS_LIBS)
 
 witherspoon_pseq_monitor_CXXFLAGS = \
 	$(PHOSPHOR_LOGGING_CFLAGS) \
 	${PHOSPHOR_DBUS_INTERFACES_CFLAGS} \
-	$(SDBUSPLUS_CFLAGS)
+	$(SDBUSPLUS_CFLAGS) \
+	$(SDEVENTPLUS_CFLAGS)
diff --git a/power-sequencer/main.cpp b/power-sequencer/main.cpp
index 87b8070..e383fc1 100644
--- a/power-sequencer/main.cpp
+++ b/power-sequencer/main.cpp
@@ -16,6 +16,7 @@
 #include <chrono>
 #include <iostream>
 #include <phosphor-logging/log.hpp>
+#include <sdeventplus/event.hpp>
 #include "argument.hpp"
 #include "pgood_monitor.hpp"
 #include "runtime_monitor.hpp"
@@ -45,16 +46,7 @@
 
     std::chrono::milliseconds interval{i};
 
-    sd_event* e = nullptr;
-    auto r = sd_event_default(&e);
-    if (r < 0)
-    {
-        log<level::ERR>("sd_event_default() failed",
-                        entry("ERROR=%s", strerror(-r)));
-        exit(EXIT_FAILURE);
-    }
-
-    event::Event event{e};
+	auto event = sdeventplus::Event::get_default();
     auto bus = sdbusplus::bus::new_default();
     bus.attach_event(event.get(), SD_EVENT_PRIORITY_NORMAL);
 
diff --git a/power-sequencer/pgood_monitor.cpp b/power-sequencer/pgood_monitor.cpp
index 02f1725..b9995c6 100644
--- a/power-sequencer/pgood_monitor.cpp
+++ b/power-sequencer/pgood_monitor.cpp
@@ -66,16 +66,6 @@
 }
 
 
-void PGOODMonitor::exitEventLoop()
-{
-    auto r = sd_event_exit(event.get(), EXIT_SUCCESS);
-    if (r < 0)
-    {
-        log<level::ERR>("sd_event_exit failed",
-                entry("RC = %d", r));
-    }
-}
-
 void PGOODMonitor::analyze()
 {
     //Timer callback.
@@ -93,8 +83,7 @@
 
     //The pgood-wait service (with a longer timeout)
     //will handle powering off the system.
-
-    exitEventLoop();
+    event.exit(EXIT_SUCCESS);
 }
 
 void PGOODMonitor::propertyChanged()
@@ -104,8 +93,7 @@
     if (!pgoodPending())
     {
         //PGOOD is on, or system is off, so we are done.
-        timer.stop();
-        exitEventLoop();
+        event.exit(EXIT_SUCCESS);
     }
 }
 
@@ -134,13 +122,7 @@
         }
 
         timer.start(interval);
-
-        auto r = sd_event_loop(event.get());
-        if (r < 0)
-        {
-            log<level::ERR>("sd_event_loop() failed",
-                    entry("ERROR=%d", r));
-        }
+        return event.loop();
     }
     catch (std::exception& e)
     {
diff --git a/power-sequencer/pgood_monitor.hpp b/power-sequencer/pgood_monitor.hpp
index 9cbda60..14a2735 100644
--- a/power-sequencer/pgood_monitor.hpp
+++ b/power-sequencer/pgood_monitor.hpp
@@ -2,8 +2,8 @@
 
 #include <sdbusplus/bus.hpp>
 #include <sdbusplus/server.hpp>
+#include <sdeventplus/event.hpp>
 #include "device.hpp"
-#include "event.hpp"
 #include "device_monitor.hpp"
 #include "timer.hpp"
 
@@ -45,7 +45,7 @@
          */
         PGOODMonitor(std::unique_ptr<witherspoon::power::Device>&& d,
                 sdbusplus::bus::bus& b,
-                witherspoon::power::event::Event& e,
+                const sdeventplus::Event& e,
                 std::chrono::milliseconds& t) :
             DeviceMonitor(std::move(d), e, t),
             bus(b)
diff --git a/power-sequencer/runtime_monitor.hpp b/power-sequencer/runtime_monitor.hpp
index de71dcf..d37cdc0 100644
--- a/power-sequencer/runtime_monitor.hpp
+++ b/power-sequencer/runtime_monitor.hpp
@@ -2,8 +2,8 @@
 
 #include <sdbusplus/bus.hpp>
 #include <sdbusplus/server.hpp>
+#include <sdeventplus/event.hpp>
 #include "device.hpp"
-#include "event.hpp"
 #include "device_monitor.hpp"
 #include "timer.hpp"
 
@@ -51,7 +51,7 @@
          */
         RuntimeMonitor(std::unique_ptr<witherspoon::power::Device>&& d,
                 sdbusplus::bus::bus& b,
-                witherspoon::power::event::Event& e,
+                const sdeventplus::Event& e,
                 std::chrono::milliseconds& i) :
             DeviceMonitor(std::move(d), e, i),
             bus(b),