mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 05:34:48 +02:00
IoEngine: allow to bind to rvalue Executor
objects
Don't require the Executor to be of type non-const reference but allow it to be a forwarding reference instead. This allows us to use`IoEngine::SpawnCoroutine()` with both lvalue and rvalue executors.
This commit is contained in:
parent
42cee50cc0
commit
1d29260d77
@ -103,8 +103,8 @@ public:
|
||||
#endif /* _WIN32 */
|
||||
}
|
||||
|
||||
template <typename Handler, typename Function>
|
||||
static void SpawnCoroutine(Handler& h, Function f) {
|
||||
template <typename Executor, typename Function>
|
||||
static void SpawnCoroutine(Executor&& e, Function f) {
|
||||
auto wrapper = [f = std::move(f)](boost::asio::yield_context yc) {
|
||||
try {
|
||||
f(yc);
|
||||
@ -123,13 +123,14 @@ public:
|
||||
};
|
||||
|
||||
#if BOOST_VERSION >= 108700
|
||||
boost::asio::spawn(h,
|
||||
boost::asio::spawn(
|
||||
std::forward<Executor>(e),
|
||||
std::allocator_arg, boost::context::fixedsize_stack(GetCoroutineStackSize()),
|
||||
std::move(wrapper),
|
||||
boost::asio::detached
|
||||
);
|
||||
#else // BOOST_VERSION >= 108700
|
||||
boost::asio::spawn(h, std::move(wrapper), boost::coroutines::attributes(GetCoroutineStackSize()));
|
||||
boost::asio::spawn(std::forward<Executor>(e), std::move(wrapper), boost::coroutines::attributes(GetCoroutineStackSize()));
|
||||
#endif // BOOST_VERSION >= 108700
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user