diff options
author | Vernon Mauery <vernon.mauery@linux.intel.com> | 2018-10-24 13:52:22 -0700 |
---|---|---|
committer | Vernon Mauery <vernon.mauery@linux.intel.com> | 2018-12-11 16:39:05 +0000 |
commit | cbccb05ab1ea1a9ad23cd8204722044122a49595 (patch) | |
tree | d07595edc71b2360ec52f40437d68540b3d56e87 /main.cpp | |
parent | 99b878493c8864e284bf8970134c7847af65b05b (diff) | |
download | phosphor-net-ipmid-cbccb05ab1ea1a9ad23cd8204722044122a49595.tar.gz phosphor-net-ipmid-cbccb05ab1ea1a9ad23cd8204722044122a49595.zip |
netipmid: move event loop to boost::asio::io_context
Replacing the event loop with asio provides for more flexibility and
less code than the sd_event model. Intially, this will require the loop
to handle both sd_events with a wrapper, but after all the sd_event
sources are replaced with asio event sources the wrapper can be removed.
Change-Id: Icf020c6c26a214bb1239641733c89603501c0c49
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
Diffstat (limited to 'main.cpp')
-rw-r--r-- | main.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
@@ -13,19 +13,20 @@ #include <dirent.h> #include <dlfcn.h> #include <host-ipmid/ipmid-api.h> -#include <systemd/sd-bus.h> #include <systemd/sd-daemon.h> #include <systemd/sd-event.h> #include <unistd.h> #include <iostream> +#include <sdbusplus/asio/connection.hpp> #include <sdbusplus/timer.hpp> #include <tuple> // Tuple of Global Singletons +static auto io = std::make_shared<boost::asio::io_context>(); session::Manager manager; command::Table table; -eventloop::EventLoop loop; +eventloop::EventLoop loop(io); sol::Manager solManager; std::tuple<session::Manager&, command::Table&, eventloop::EventLoop&, @@ -118,9 +119,8 @@ int main() { std::cerr << "Failed to connect to system bus:" << strerror(-rc) << "\n"; - goto finish; + return rc; } - sdbusp = std::make_shared<sdbusplus::bus::bus>(bus); /* Get an sd event handler */ rc = sd_event_default(&events); @@ -129,6 +129,7 @@ int main() std::cerr << "Failure to create sd_event" << strerror(-rc) << "\n"; return EXIT_FAILURE; } + sdbusp = std::make_shared<sdbusplus::asio::connection>(*io, bus); // Register callback to update cache for a GUID change and cache the GUID command::registerGUIDChangeCallback(); @@ -144,11 +145,5 @@ int main() sol::command::registerCommands(); // Start Event Loop - return std::get<eventloop::EventLoop&>(singletonPool) - .startEventLoop(events); - -finish: - sd_event_unref(events); - - return 0; + return std::get<eventloop::EventLoop&>(singletonPool).startEventLoop(); } |