sdbus::asio: service sd_event loop upon request

If requested, add in an asynchronous sd_event servicing mechanism so
sd_events can be used in conjunction with boost::asio events. Code
throughout the openbmc repositories use sd_events, especially for
timers. In some cases, we may want to add boost::asio event handling for
superior asynchronous eventing, but not want to rewrite all the existing
sd_event code. This gives us the best of both worlds, with a
low-overhead mechanism to handle the sd_events.

Change-Id: I3f8e2aafa3f733439e1494253698d17c2f3a2321
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
diff --git a/example/asio-example.cpp b/example/asio-example.cpp
index 354c7b0..cced85d 100644
--- a/example/asio-example.cpp
+++ b/example/asio-example.cpp
@@ -4,8 +4,10 @@
 #include <iostream>
 #include <sdbusplus/asio/connection.hpp>
 #include <sdbusplus/asio/object_server.hpp>
+#include <sdbusplus/asio/sd_event.hpp>
 #include <sdbusplus/bus.hpp>
 #include <sdbusplus/server.hpp>
+#include <sdbusplus/timer.hpp>
 
 int foo(int test)
 {
@@ -130,6 +132,15 @@
 
     iface->initialize();
     iface->set_property("int", 45);
+
+    // sd_events work too using the default event loop
+    phosphor::Timer t1([]() { std::cerr << "*** tock ***\n"; });
+    t1.start(std::chrono::microseconds(1000000));
+    phosphor::Timer t2([]() { std::cerr << "*** tick ***\n"; });
+    t2.start(std::chrono::microseconds(500000), true);
+    // add the sd_event wrapper to the io object
+    sdbusplus::asio::sd_event_wrapper sdEvents(io);
+
     io.run();
 
     return 0;