Use asio object_server without boost::coroutine
We already support this flag in asio::connection and other places, where
it's used to avoid compatibility issues with boost coroutine v1, which
is a package that isn't widely used, and requires explicitly built
libraries (coroutine and context).
This commit supports the same flag in ASIO object server, for things
like dbus-sensors, which doesn't make use of asio coroutines.
Change-Id: I75deec77f4434e671fe5028cad14fd9998cf9b40
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/include/sdbusplus/asio/object_server.hpp b/include/sdbusplus/asio/object_server.hpp
index 57dcc95..1de8bed 100644
--- a/include/sdbusplus/asio/object_server.hpp
+++ b/include/sdbusplus/asio/object_server.hpp
@@ -5,7 +5,10 @@
// but by defining it here, warnings won't cause problems with a compile
#define BOOST_COROUTINES_NO_DEPRECATION_WARNING
#endif
+
+#ifndef SDBUSPLUS_DISABLE_BOOST_COROUTINES
#include <boost/asio/spawn.hpp>
+#endif
#include <sdbusplus/asio/connection.hpp>
#include <sdbusplus/exception.hpp>
#include <sdbusplus/message/read.hpp>
@@ -87,12 +90,18 @@
const char* signature_;
};
+#ifndef SDBUSPLUS_DISABLE_BOOST_COROUTINES
template <typename T>
inline const bool FirstArgIsYield_v =
std::is_same_v<utility::get_first_arg_t<utility::decay_tuple_t<
boost::callable_traits::args_t<T>>>,
boost::asio::yield_context>;
+#else
+template <typename T>
+inline const bool FirstArgIsYield_v = false;
+#endif
+
template <typename T>
inline const bool FirstArgIsMessage_v =
std::is_same_v<utility::get_first_arg_t<utility::decay_tuple_t<
@@ -130,12 +139,14 @@
{
constexpr static std::size_t size()
{
+#ifndef SDBUSPLUS_DISABLE_BOOST_COROUTINES
if constexpr (std::is_same_v<FirstArg, message_t> ||
std::is_same_v<FirstArg, boost::asio::yield_context>)
{
return 1 + NonDbusArgsCount<std::tuple<OtherArgs...>>::size();
}
else
+#endif
{
return NonDbusArgsCount<std::tuple<OtherArgs...>>::size();
}
@@ -210,6 +221,7 @@
}
};
+#ifndef SDBUSPLUS_DISABLE_BOOST_COROUTINES
template <typename CallbackType>
class coroutine_method_instance
{
@@ -288,6 +300,7 @@
}
}
};
+#endif
template <typename PropertyType, typename CallbackType>
class callback_get_instance