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>
diff --git a/sd_event_loop.hpp b/sd_event_loop.hpp
index 2faa7ad..5218b27 100644
--- a/sd_event_loop.hpp
+++ b/sd_event_loop.hpp
@@ -4,6 +4,7 @@
#include <systemd/sd-event.h>
+#include <boost/asio/io_context.hpp>
#include <chrono>
#include <map>
@@ -42,7 +43,10 @@
class EventLoop
{
public:
- EventLoop() = default;
+ explicit EventLoop(std::shared_ptr<boost::asio::io_context> io) : io(io)
+ {
+ }
+ EventLoop() = delete;
~EventLoop() = default;
EventLoop(const EventLoop&) = delete;
EventLoop& operator=(const EventLoop&) = delete;
@@ -67,11 +71,10 @@
/** @brief Initialise the event loop and add the handler for incoming
* IPMI packets.
- * @param[in] events- sd bus event;
*
* @return EXIT_SUCCESS on success and EXIT_FAILURE on failure.
*/
- int startEventLoop(sd_event* events);
+ int startEventLoop();
/** @brief Add host console I/O event source to the event loop.
*
@@ -139,6 +142,10 @@
/** @brief Event source object for host console. */
EventSource hostConsole = nullptr;
+ /** @brief boost::asio io context to run with
+ */
+ std::shared_ptr<boost::asio::io_context> io;
+
/** @brief Event source for the UDP socket listening on IPMI standard
* port.
*/